VectorView
Hierarchy
- Vector
- VectorView
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Parameters
options: VectorViewOptions
Returns VectorView
Properties
publicstaticinheritedEQUALS_EPSILON
Get or set the vector equals epsilon, by default 0.001 meaning vectors within that tolerance on x or y will be considered equal.
Accessors
publicinheritedmagnitude
The magnitude (length) of the Vector
Returns number
Setting the size mutates the current vector
Parameters
newMagnitude: number
Returns void
publicinheritedsize
The size (magnitude) of the Vector
Returns number
Setting the size mutates the current vector
Parameters
newLength: number
Returns void
publicx
Get the x component of the vector
Returns number
Get the x component of the vector
Parameters
val: number
Returns void
publicy
Get the y component of the vector
Returns number
Get the y component of the vector
Parameters
val: number
Returns void
publicstaticinheritedDown
A unit vector pointing down (0, 1)
Returns Vector
publicstaticinheritedHalf
A (0.5, 0.5) vector
Returns Vector
publicstaticinheritedLeft
A unit vector pointing left (-1, 0)
Returns Vector
publicstaticinheritedOne
A (1, 1) vector
Returns Vector
publicstaticinheritedRight
A unit vector pointing right (1, 0)
Returns Vector
publicstaticinheritedUp
A unit vector pointing up (0, -1)
Returns Vector
publicstaticinheritedZero
A (0, 0) vector
Returns Vector
Methods
publicinheritedadd
publicinheritedaddEqual
publicinheritedangleBetween
Returns the difference in radians between the angle of this vector and given angle, using the given rotation type.
Parameters
angle: number
in radians to which the vector has to be rotated, using rotate
rotationType: RotationType
what RotationType to use for the rotation
Returns number
the angle by which the vector needs to be rotated to match the given angle
publicinheritedaverage
publicinheritedclampMagnitude
Clamps the current vector's magnitude mutating it
Parameters
magnitude: number
Returns Vector
publicinheritedclone
publicinheritedcross
Performs a 2D cross product with scalar. 2D cross products with a scalar return a vector.
Parameters
v: number
The scalar to cross
Returns Vector
publicinheriteddistance
The distance to another vector. If no other Vector is specified, this will return the magnitude.
Parameters
optionalv: Vector
The other vector. Leave blank to use origin vector.
Returns number
publicinheriteddot
Performs a dot product with another vector
Parameters
v: Vector
The vector to dot
Returns number
publicinheritedequals
Compares this point against another and tests for equality
Parameters
vector: Vector
The other point to compare to
tolerance: number = Vector.EQUALS_EPSILON
Amount of euclidean distance off we are willing to tolerate
Returns boolean
publicinheritedlerp
Linearly interpolates between the current vector and the target vector. At
t = 0, the result is the current vector, and att = 1, the result is the target vector. Values oftoutside the range [0, 1] will be clamped to that range.Parameters
target: Vector
The target vector to interpolate towards.
t: number
The interpolation factor, clamped between 0 and 1.
Returns Vector
A new vector that is the result of the linear interpolation.
publicinheritednegate
Negate the current vector
Returns Vector
publicinheritednormal
Returns the normal vector to this one, same as the perpendicular of length 1
Returns Vector
publicinheritednormalize
Normalizes a non-zero vector to have a magnitude of 1. Zero vectors return a new zero vector.
Returns Vector
publicinheritedperpendicular
Returns the perpendicular vector to this one
Returns Vector
publicinheritedrotate
publicinheritedscale
publicinheritedscaleEqual
Scales this vector by a factor of size and modifies the original
Parameters
size: number
Returns Vector
inheritedsetTo
Sets the x and y components at once, THIS MUTATES the current vector. It is usually better to create a new vector.
Parameters
x: number
y: number
Returns void
publicinheritedsquareDistance
Parameters
optionalv: Vector
Returns number
publicinheritedsub
publicinheritedsubEqual
publicinheritedtoAngle
Returns the angle of this vector, in range [0, 2*PI)
Returns number
publicinheritedtoString
Returns a string representation of the vector.
Parameters
optionalfixed: number
Returns string
staticinheritedcross
publicstaticinheriteddistance
publicstaticinheritedfromAngle
Returns a vector of unit length in the direction of the specified angle in Radians.
Parameters
angle: number
The angle to generate the vector
Returns Vector
publicstaticinheritedisValid
Checks if vector is not null, undefined, or if any of its components are NaN or Infinity.
Parameters
vec: Vector
Returns boolean
A 2D vector on a plane.