Math module

Vector2

structSource

A 2D vector with fields x and y, also reachable as the array component. Supports + - * / (component-wise or by a scalar), unary -, ==, and the procedures dot, length, distance, lerp, min, max, abs, unit_vector and rotate.

ExampleOpen in playground ↗
v := Vector2.{ 3, 4 };
assert(v.x == 3 && v.component[1] == 4);
assert(length(v) == 5);
assert(v * 2 == xy(6, 8));

Fields

x: float
y: float
component: [2] float

See also