Skip to content

Vec

Auto-generated from src/stdlib/vec.mcrs — do not edit manually.

API


dot2d v1.0.0

Dot product of two 2D integer vectors.

redscript
fn dot2d(ax: int, ay: int, bx: int, by: int) -> int

Parameters

ParameterDescription
axX component of vector A
ayY component of vector A
bxX component of vector B
byY component of vector B

Returns: axbx + ayby

Example

redscript
let d = dot2d(3, 4, 3, 4)  // result: 25

length2d_fixed v1.0.0

Euclidean length of a 2D vector, returned as ×1000 fixed-point.

redscript
fn length2d_fixed(x: int, y: int) -> int

Parameters

ParameterDescription
xX component (raw integer; keep
yY component

Returns: sqrt(x²+y²) × 1000

Example

redscript
let l = length2d_fixed(3, 4)  // result: 5000

dot3d v1.0.0

Dot product of two 3D integer vectors.

redscript
fn dot3d(ax: int, ay: int, az: int, bx: int, by: int, bz: int) -> int

Parameters

ParameterDescription
axX component of vector A
ayY component of vector A
azZ component of vector A
bxX component of vector B
byY component of vector B
bzZ component of vector B

Returns: axbx + ayby + az*bz

Example

redscript
let d = dot3d(1, 0, 0, 1, 0, 0)  // result: 1

cross3d_x v1.0.0

X component of the cross product A×B (aybz − azby).

redscript
fn cross3d_x(ax: int, ay: int, az: int, bx: int, by: int, bz: int) -> int

Parameters

ParameterDescription
axX of A @param ay Y of A @param az Z of A
bxX of B @param by Y of B @param bz Z of B

Returns: aybz - azby


cross3d_y v1.0.0

Y component of the cross product A×B (azbx − axbz).

redscript
fn cross3d_y(ax: int, ay: int, az: int, bx: int, by: int, bz: int) -> int

Parameters

ParameterDescription
axX of A @param ay Y of A @param az Z of A
bxX of B @param by Y of B @param bz Z of B

Returns: azbx - axbz


cross3d_z v1.0.0

Z component of the cross product A×B (axby − aybx).

redscript
fn cross3d_z(ax: int, ay: int, az: int, bx: int, by: int, bz: int) -> int

Parameters

ParameterDescription
axX of A @param ay Y of A @param az Z of A
bxX of B @param by Y of B @param bz Z of B

Returns: axby - aybx

Example

redscript
let z = cross3d_z(1, 0, 0, 0, 1, 0)  // result: 1

Released under the MIT License.