Skip to content
Hyomoto edited this page Jun 24, 2021 · 14 revisions
Jump To Go Back Arguments Methods Variables

Vec2( x, y )

A simple, garbage-collected two-dimensional vector.

var _vec2 = new Vec2( 32, 20 );
Output: A new Vec2 is created with an x of 32 and a y of 20

Arguments

Name Type Purpose
x real The x position in this vector
y real The y position in this vector

Methods

Jump To top set len lensqr add subtract multiply divide dot cross dist_to dist_to_sqr normalize to_array toString

set( x, y )

Returns: self

Name Type Purpose
x real The x position to set this vector
y real The y position to set this vector

Used to set both the x and y coordinates in this vector with a single method.


len( )

Returns: real

Name Type Purpose
None

Used to get the vectors length.


lensqr( )

Returns: real

Name Type Purpose
None

Used to get the vectors squared length.


add( Vec2 )

Returns: Vec2

Name Type Purpose
Vec2 Vec2 The vector to subtract from this one.

No description.


subtract( Vec2 )

Returns: Vec2

Name Type Purpose
Vec2 Vec2 The vector to subtract from this one.

No description.


multiply( Vec2 )

Returns: Vec2

Name Type Purpose
Vec2 Vec2 The vector to multiply this one component wise with.

No description.


divide( Vec2 )

Returns: Vec2

Name Type Purpose
Vec2 Vec2 The vector to divide this one one component wise by.

No description.


dot( Vec2 )

Returns: real

Name Type Purpose
Vec2 Vec2 The vector to get the dot product with.

No description.


cross( Vec2 )

Returns: Vec2

Name Type Purpose
Vec2 Vec2 The vector to get the cross product with.

No description.


dist_to( Vec2 )

Returns: real

Name Type Purpose
Vec2 Vec2 The vector to get the distance to.

No description.


dist_to_sqr( Vec2 )

Returns: real

Name Type Purpose
Vec2 Vec2 The vector to get the squared distance to.

No description.


normalize( )

Returns: Vec2

Name Type Purpose
None

Used to normalise the vector to unit length.


to_array( )

Returns: array

Name Type Purpose
None

Returns this vector as an array.


toString( )

Returns: string, "x, y"

Name Type Purpose
None

Returns this vector as a comma-separated string value pair.


Variables

Jump To top
Name Type Initial Purpose
x real _x the x position of this vector
y real _y the y position of this vector
Clone this wiki locally