VectorI

Four-component integer vector (x, y, z, w)

It

Integer vector object

self {
  I32 x
  I32 y
  I32 z
  I32 w
  bool operator==(const It& o) { return x==o.x && y==o.y && z==o.z && w==o.w; }
  It operator+(const It& o) { return {x+o.x, y+o.y, z+o.z, w+o.w}; }
  It operator-(const It& o) { return {x-o.x, y-o.y, z-o.z, w-o.w}; }
  It operator-() { return {-x, -y, -z, -w}; }
  It operator*(const It& o) { return {x*o.x, y*o.y, z*o.z, w*o.w}; }
  It operator*(int s) { return {x*s, y*s, z*s, w*s}; }
  It operator/(int s) { return {x/s, y/s, z/s, w/s}; }
}

equals

Test whether two integer vectors are component-wise equal

U8 equals(VectorI a, VectorI b)

Parameters

  • a — First vector
  • b — Second vector

Returns — Non-zero if equal


set

Set all four components of an integer vector

U0 set(VectorI vec, I32 x, I32 y, I32 z, I32 w)

Parameters

  • vec — Target vector
  • x — X component
  • y — Y component
  • z — Z component
  • w — W component

normalize

Normalize an integer vector to unit length in-place

U0 normalize(VectorI vec)

Parameters

  • vec — Vector to normalize

length

Compute the length (magnitude) of an integer vector

F32 length(VectorI vec)

Parameters

  • vec — The vector

Returns — Euclidean length as float


zero

Set all components of an integer vector to zero

U0 zero(VectorI vec)

Parameters

  • vec — Vector to zero

dot

Compute the dot product of two integer vectors

I32 dot(VectorI a, VectorI b)

Parameters

  • a — First vector
  • b — Second vector

Returns — Dot product


cross

Compute the cross product of two integer vectors

U0 cross(VectorI result, VectorI a, VectorI b)

Parameters

  • result — Vector to store the result
  • a — First vector
  • b — Second vector

add

Add two integer vectors component-wise

U0 add(VectorI result, VectorI a, VectorI b)

Parameters

  • result — Vector to store the result
  • a — First vector
  • b — Second vector

sub

Subtract one integer vector from another

U0 sub(VectorI result, VectorI a, VectorI b)

Parameters

  • result — Vector to store the result
  • a — Minuend vector
  • b — Subtrahend vector

mul

Multiply two integer vectors component-wise

U0 mul(VectorI result, VectorI a, VectorI b)

Parameters

  • result — Vector to store the result
  • a — First vector
  • b — Second vector

scale

Multiply an integer vector by a scalar

U0 scale(VectorI result, VectorI a, I32 s)

Parameters

  • result — Vector to store the result
  • a — Source vector
  • s — Scalar factor

div

Divide an integer vector by a scalar

U0 div(VectorI result, VectorI a, I32 s)

Parameters

  • result — Vector to store the result
  • a — Source vector
  • s — Scalar divisor