Struct vec2

2 dimensional vector

struct vec2;

Constructors

NameDescription
this (v) create with all components filled with specified value
this (v)
this (v)
this (v)
this (x, y)

Fields

NameTypeDescription
vec float[2]
x float
y float

Properties

NameTypeDescription
magnitude[get] floatlength of vector
magnitudeSquared[get] floatsum of squares of all vector components
normalized[get] vec2returns normalized copy of this vector

Methods

NameDescription
add (v) add value to all components of vector
add (v) add components of another vector to corresponding components of this vector
clear (v) fill all components of vector with specified value
crossProduct (v2) cross product of 2 vec2 is scalar in Z axis
div (v) divide all components of vector by value
div (v) divide components of this vector by corresponding components of another vector
dot (v) dot product (sum of by-component products of vector components)
mul (v) multiply all components of vector by value
mul (v) multiply components of this vector by corresponding components of another vector
normalize () normalize vector: make its length == 1
opAssign (v)
opAssign (v)
opBinary (v) add value to all components of vector
opBinary (v) multiply all components of vector by value
opBinary (v) subtract value from all components of vector
opBinary (v) divide all components of vector by value
opBinary (v) add value to all components of vector
opBinary (v) subtract value from all components of vector
opOpAssign (v) add value to all components of vector
opOpAssign (v) multiply all components of vector by value
opOpAssign (v) subtract value from all components of vector
opOpAssign (v) divide all components of vector by value
opOpAssign (v) by component add values of corresponding components of other vector
opOpAssign (v) by component multiply values of corresponding components of other vector
opOpAssign (v) by component subtract values of corresponding components of other vector
opOpAssign (v) by component divide values of corresponding components of other vector
opUnary () returns vector with all components which are negative of components for this vector
rotated90ccw () returns vector rotated 90 degrees counter clockwise
rotated90cw () returns vector rotated 90 degrees clockwise
sub (v) subtract value from all components of vector
sub (v) subtract components of another vector from corresponding components of this vector

Aliases

NameDescription
length
u
v