Import std.math.vector
Vec2
struct
Public Struct Vec2 Implements Numeric, Hashable, Printable, Defaultable
A point or direction in 2D.
Examples
Local v = Vec2(3, 4)
Expect(Length(v) == 5.0 && Distance(v, Vec2(0, 0)) == 5.0)
Expect(Perpendicular(Vec2(1, 0)) == Vec2(0, 1))
Expect(IsClose(Rotate(Vec2(1, 0), Deg(90)), Vec2(0, 1)))-
Its x component.
-
Its y component.
-
The zero vector, (0, 0).
-
The vector (1, 1), which multiplying leaves alone.
-
The zero vector, (0, 0).
-
The components as Ints, toward 0, as As converts them: one outside an Int's range panics.
-
Its components, as "(1, 2)".
-
The component at the index: x at 0, and y at 1. Any other index panics.
-
aplusb, component by component. -
aminusb, component by component. -
atimesb, component by component. -
adivided byb, component by component. -
atimesscale. -
scaletimesa. -
adivided byscale. -
anegated.
Report an issue with this page or with FutureBlitz on GitHub.