Skip to content

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

math ​

Utilities for mathematical operations, including vector and matrix math.

Classes ​

ClassDescription
OrientationAxis-aligned orientation for Stormworks' left-handed coordinate system.

Interfaces ​

InterfaceDescription
Vec2A simple two-dimensional numeric vector.
ReadonlyVec2Read only Vec2 type.
AxisMappingMapping from an output axis to a signed input axis. Used in Orientation.
Vec3A simple three-dimensional numeric vector.
ReadonlyVec3Read only Vec3 type.

Type Aliases ​

Type AliasDescription
Mat3A simple 3x3 matrix.
ReadonlyMat3Read only Mat3 type.
AxisAxis name used by an axis-aligned orientation. Used in Orientation.

Functions ​

FunctionDescription
moduloPositive modulo, useful for cyclic indices.
isMat3Return true when value is a nine-number array.
transposeMat3Return the transpose of a row-major 3x3 matrix.
mulMat3Multiply two row-major 3x3 matrices.
mulMat3Vec3Transform a vector by a row-major 3x3 matrix.
detMat3Return the determinant of a row-major 3x3 matrix.
parseMat3Parse a comma-separated row-major 3x3 matrix.
vec3Create a full vector from a partial value, using 0 for omitted components.
minVec3Return the component-wise minimum of two vectors.
maxVec3Return the component-wise maximum of two vectors.
addVec3Add two vectors component-wise.
subVec3Subtract b from a component-wise.
mulVec3Multiply every component by a scalar.
dotVec3Return the dot product of two vectors.
crossVec3Return the right-handed cross product a x b.
normalizeVec3Return a unit-length vector in the same direction as v.
eqVec3Return true when all vector components are exactly equal.