Skip to content

Documentation / @sw-file-lib/core / math / Orientation

Class: Orientation ​

ts
class Orientation {
  constructor(x: AxisMapping, y: AxisMapping, z: AxisMapping);
  readonly x: AxisMapping;
  readonly y: AxisMapping;
  readonly z: AxisMapping;
  readonly Identity: Orientation;
  readonly RotateX90: Orientation;
  readonly RotateX180: Orientation;
  readonly RotateX270: Orientation;
  readonly RotateY90: Orientation;
  readonly RotateY180: Orientation;
  readonly RotateY270: Orientation;
  readonly RotateZ90: Orientation;
  readonly RotateZ180: Orientation;
  readonly RotateZ270: Orientation;
  readonly FlipX: Orientation;
  readonly FlipY: Orientation;
  readonly FlipZ: Orientation;
  multiply(other: Orientation): Orientation;
  transformPosition(src: ReadonlyVec3): Vec3;
  toMat3(): Mat3;
  equals(other: Orientation): boolean;
}

Defined in: math/orientation.ts:20

Axis-aligned orientation for Stormworks' left-handed coordinate system.

Rotations use Stormworks-positive directions (x right, y up, z forward). toMat3() returns a row-major matrix.

Constructors ​

Constructor ​

ts
new Orientation(
   x: AxisMapping, 
   y: AxisMapping, 
   z: AxisMapping): Orientation;

Defined in: math/orientation.ts:22

Create an orientation from signed mappings for the output x, y, and z axes.

Parameters ​

ParameterType
xAxisMapping
yAxisMapping
zAxisMapping

Returns ​

Orientation

Properties ​

x ​

ts
readonly x: AxisMapping;

Defined in: math/orientation.ts:23


y ​

ts
readonly y: AxisMapping;

Defined in: math/orientation.ts:24


z ​

ts
readonly z: AxisMapping;

Defined in: math/orientation.ts:25


Identity ​

ts
readonly static Identity: Orientation;

Defined in: math/orientation.ts:29

No rotation or reflection.


RotateX90 ​

ts
readonly static RotateX90: Orientation;

Defined in: math/orientation.ts:36

Positive 90 degree rotation around the X axis in Stormworks left-handed space.


RotateX180 ​

ts
readonly static RotateX180: Orientation;

Defined in: math/orientation.ts:43

180 degree rotation around the X axis.


RotateX270 ​

ts
readonly static RotateX270: Orientation;

Defined in: math/orientation.ts:50

Positive 270 degree rotation around the X axis in Stormworks left-handed space.


RotateY90 ​

ts
readonly static RotateY90: Orientation;

Defined in: math/orientation.ts:57

Positive 90 degree rotation around the Y axis in Stormworks left-handed space.


RotateY180 ​

ts
readonly static RotateY180: Orientation;

Defined in: math/orientation.ts:64

180 degree rotation around the Y axis.


RotateY270 ​

ts
readonly static RotateY270: Orientation;

Defined in: math/orientation.ts:71

Positive 270 degree rotation around the Y axis in Stormworks left-handed space.


RotateZ90 ​

ts
readonly static RotateZ90: Orientation;

Defined in: math/orientation.ts:78

Positive 90 degree rotation around the Z axis in Stormworks left-handed space.


RotateZ180 ​

ts
readonly static RotateZ180: Orientation;

Defined in: math/orientation.ts:85

180 degree rotation around the Z axis.


RotateZ270 ​

ts
readonly static RotateZ270: Orientation;

Defined in: math/orientation.ts:92

Positive 270 degree rotation around the Z axis in Stormworks left-handed space.


FlipX ​

ts
readonly static FlipX: Orientation;

Defined in: math/orientation.ts:99

Mirror across the X axis.


FlipY ​

ts
readonly static FlipY: Orientation;

Defined in: math/orientation.ts:106

Mirror across the Y axis.


FlipZ ​

ts
readonly static FlipZ: Orientation;

Defined in: math/orientation.ts:113

Mirror across the Z axis.

Methods ​

multiply() ​

ts
multiply(other: Orientation): Orientation;

Defined in: math/orientation.ts:120

Compose this orientation with another orientation.

Parameters ​

ParameterType
otherOrientation

Returns ​

Orientation


transformPosition() ​

ts
transformPosition(src: ReadonlyVec3): Vec3;

Defined in: math/orientation.ts:133

Transform a position or direction vector by this orientation.

Parameters ​

ParameterType
srcReadonlyVec3

Returns ​

Vec3


toMat3() ​

ts
toMat3(): Mat3;

Defined in: math/orientation.ts:144

Convert this orientation to a row-major 3x3 matrix.

Returns ​

Mat3


equals() ​

ts
equals(other: Orientation): boolean;

Defined in: math/orientation.ts:160

Return true when both orientations describe the same axis mapping.

Parameters ​

ParameterType
otherOrientation

Returns ​

boolean