Math module

scale

procedure · 4 overloadsSource

Multiplies the columns of a matrix by s (all three) or by v.x, v.y, v.z respectively, which is m * scale_matrix: the scale is applied to points first, then m's own transform. Works on Matrix3 and Matrix4; a pointer scales in place. The translation column of a Matrix4 is not scaled.

ExampleOpen in playground ↗
m := Matrix3_Identity;
scaled := scale(m, 2.0);
assert(scaled * xyz(1, 1, 1) == xyz(2, 2, 2));
m2 := scale(Matrix3_Identity, xyz(1, 2, 3));
assert(m2 * xyz(1, 1, 1) == xyz(1, 2, 3));
scale :: (m: $T/interface AnyMatrix3, s: float) -> T

m scaled by the same factor on all three axes.

Parameters

m: $T/interface AnyMatrix3
the matrix.
s: float
the scale factor.

Returns

T
scale :: (m: *$T/interface AnyMatrix3, s: float)

Scales the matrix by the same factor on all three axes, in place.

Parameters

m: *$T/interface AnyMatrix3
the matrix to change.
s: float
the scale factor.
scale :: (m: $T/interface AnyMatrix3, v: Vector3) -> T

m scaled per axis.

Parameters

m: $T/interface AnyMatrix3
the matrix.
v: Vector3
the scale on x, y and z.

Returns

T
scale :: (m: *$T/interface AnyMatrix3, v: Vector3)

Scales the matrix per axis, in place.

Parameters

m: *$T/interface AnyMatrix3
the matrix to change.
v: Vector3
the scale on x, y and z.

See also