Vector | CraytaKit
Skip to main content

Vector

Constructors

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

Class Functions

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

Functions

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

Properties

Property NameReturn TypeDescriptionTags
xnumberX component of 3D vectorNone
ynumberY component of 3D vectorNone
znumberZ component of 3D vectorNone

Constants

Constant NameReturn TypeDescriptionTags
ZeroVectorZero vector (0, 0, 0)None

Overrides

Override NameReturn TypeDescriptionTags
+VectorAdd two Vector values together and return a new Vector of the resultNone
-VectorSubtract two Vector values and return a new Vector of the resultNone
unary_minusVectorNegate a Vector value and return the resultNone
*VectorMultiply a Vector by a number, returning a VectorNone
/VectorDivide a Vector by a number, returning a VectorNone
to_stringstringConvert to a stringNone

Examples

© 2021 CraytaKit