Math module

Vector3

structSource

A 3D vector with fields x, y, z, also reachable as the array component; xy and yz view two of the fields as a Vector2. Supports + - * / (component-wise or by a scalar, including a float64 scalar that is narrowed to float), unary -, ==, and the procedures dot, cross, length, distance, lerp, min, max, abs, unit_vector and rotate (by a quaternion).

ExampleOpen in playground ↗
v := Vector3.{ 1, 2, 3 };
assert(v.xy == xy(1, 2) && v.yz == xy(2, 3));
assert(v / 2 == xyz(0.5, 1, 1.5));
assert(-v == xyz(-1, -2, -3));

Fields

x: float
y: float
z: float
component: [3] float

See also