Vector2

by Kaiochao
2D vector datum for positions and offsets. [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Kaiochao.Vector2##version=4

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Kaiochao.Vector2##version=4

132 downloads
Version 4
Date added: Jul 14 2017
Last updated: Jul 27
0 fans
2D vector datum for positions and offsets.
var/Vector2/Vector2 = new

Vector2
var
vector2
Zero = new(0, 0)
One = new(1, 1)
North = new(0, 1)
South = new(0, -1)
East = new(1, 0)
West = new(-1, 0)
Northeast = new(sqrt(1/2), sqrt(1/2))
Northwest = new(-sqrt(1/2), sqrt(1/2))
Southeast = new(sqrt(1/2), -sqrt(1/2))
Southwest = new(-sqrt(1/2), -sqrt(1/2))

proc
FromDir(dir)

vector2
var x, y

New(x = 0, y = 0)
New(vector2/to_copy)

proc
operator~=(vector2/v)

operator+(vector2/v)
operator-(vector2/v)

operator*(s)
operator/(d)

Dot(vector2/v)
Cross(vector2/v)

SquareMagnitude()
Magnitude()

ToMagnitude(m)
Normalized()

ToText(SigFig = 6)

operator[](index)

Rotation() return RotationFrom(Vector2.North)
RotationFrom(vector2/from_vector = Vector2.North)

Turn(angle)

matrix
Translate(vector2/v)
Scale(vector2/v)


Includes:
- Hypot for magnitude calculation.

7/27/2019
Updated documentation.
Changed ToText's default sig-figs to 6 (apparently passing null to num2text's sig-figs doesn't make it default properly).