Vector2D | CraytaKit
Skip to main content

Vector2D

Constructors

Constructor NameReturn TypeDescriptionTags
Vector2D.New(number x, number y, number z)Vector2DConstruct a new Vector2D with the given x, y and z components, where z is generally upNone

Class Functions

Class Function NameReturn TypeDescriptionTags
Vector2D.Distance(Vector2D vec1, Vector2D vec2)numberReturn the distance between two Vector2D valuesNone
Vector2D.SquaredDistance(Vector2D vec1, Vector2D vec2)numberReturn the square of the distance of two Vector2D valuesNone
Vector2D.Cross(Vector2D vec1, Vector2D vec2)Vector2DReturn the cross product of two Vector2D valuesNone
Vector2D.Dot(Vector2D vec1, Vector2D vec2)numberReturn the dot product of two Vector2D valuesNone
Vector2D.Lerp(Vector2D vec1, Vector2D vec2)Vector2DLinearly interpolate between vec1 and vec2 by the fraction alpha, where alpha is normally in the range [0,1]None

Functions

Function NameReturn TypeDescriptionTags
Normalize()Vector2DReturn a normalized Vector2D (where the length is 1.0)None
Length()numberReturn the length of the given Vector2DNone
SquaredLength()numberReturn the square of the length of the given Vector2DNone
Abs()Vector2DReturn a Vector2D constructed from the absolute (ie positive or zero) x, y and z components of the given Vector2DNone
Ceil()Vector2DReturns a Vector2D constructed from the ceiling (ie next integer value) x, y and z components of the given Vector2DNone
Floor()Vector2DReturns a Vector2D constructed from the floor (ie integer value below) x, y and z components of the given Vector2DNone

Properties

Property NameReturn TypeDescriptionTags
xnumberX component of 2D VectorNone
ynumberY component of 2D VectorNone
znumberZ component of 2D VectorNone

Constants

Constant NameReturn TypeDescriptionTags
ZeroVector2DZero Vector2D (0, 0)None

Overrides

Override NameReturn TypeDescriptionTags
+Vector2DAdd two Vector2D values together and return a new Vector2D of the resultNone
-Vector2DSubtract two Vector2D values and return a new Vector2D of the resultNone
unary_minusVector2DNegate a Vector2D value and return the resultNone
*Vector2DMultiply a Vector2D by a number, returning a Vector2DNone
/Vector2DDivide a Vector2D by a number, returning a Vector2DNone
to_stringstringConvert to a stringNone

Examples

© 2021 CraytaKit