Vec2

constructor

new Vec2(_x, _y)

Description

Constructor function for 2d vectors

Arguments

Name Type Description
_x real The x component of the vector.
_y real The y component of the vector.

Properties

Name Description
x The x component of the vector.
y The y component of the vector.

Methods

Name Description
add Adds the specified vector to this vector.
add_new Adds the specified vector to this vector.
angle_to Calculates the angle from self to another vector.
cmpeq Performs a vertical == comparison between self and _vector.
cmpge Performs a vertical >= comparison between self and _vector.
cmpgt Performs a vertical > comparison between self and _vector.
cmple Performs a vertical <= comparison between self and _vector.
cmplt Performs a vertical < comparison between self and _vector.
cmpne Performs a vertical != comparison between self and _vector.
cross Returns the cross product of this vector and the specified vector.
distance Calculates the distance between self and another vector.
dot Returns the dot product of this vector and the specified vector.
extend Creates a new Vec3 from self and the given z value.
is_normalized Checks whether self is normalized.
length Calculates the length of self.
length_squared Calculates the square of the length of self.
lerpy Linearly interpolates between two points. Interpolates between the points self and _finish by the interpolant _amt. The parameter _amt is clamped to the range [0, 1].
max_element Calculates the horizontal maximum of self's elements.
max_elements Calculates the vertical maximum of self's and _vector's elements.
min_element Calculates the horizontal minimum of self's elements.
min_elements Calculates the vertical minimum of self's and _vector's elements.
mirror Mirrors the vector off the vector defined by a normal.
negate Negates the vector.
normalize Normalizes the vector
one Creates a Vec2 with all elements set to 1.
ortho Returns a new orthogonal vector
reflect Reflects the vector off the vector defined by a mirror 'plane'.
scalar_div Divides every component of the vector by a scalar.
scalar_mul Multiplies every component of the vector with a scalar.
set Replaces both components of the vector with new ones.
sub Substracts the specified vector from this vector.
sub_new Substracts the specified vector from this vector.
to_string Converts the components of self to a string.
unit_x Creates a Vec2 with values { x: 1, y: 0 }.
unit_y Creates a Vec2 with values { x: 0, y: 1 }.
zero Creates a Vec2 with all elements set to 0.

Example

vec1 = new Vec2(2, 5);

Copyright © 2020, eL-Falso. Built on December 14, 2020 using GMDoc.