Vec3 Class
3-dimensional vector
Constructor
Vec3
-
x -
y -
z
Parameters:
-
xNumber -
yNumber -
zNumber
Example:
var v = new Vec3(1, 2, 3);
console.log('x=' + v.x); // x=1
Item Index
Methods
Methods
almostEquals
-
v -
precision
Check if a vector equals is almost equal to another one.
Parameters:
-
vVec3 -
precisionNumber
Returns:
bool
almostZero
-
precision
Check if a vector is almost zero
Parameters:
-
precisionNumber
copy
-
source
Copies value of source to this vector.
Parameters:
-
sourceVec3
Returns:
this
crossmat
()
Mat3
Get the cross product matrix a_cross from a vector, such that a x b = a_cross * b = c
Returns:
distanceTo
-
p
Get distance from this point to another point
Parameters:
-
pVec3
Returns:
isAntiparallelTo
-
v -
precision
Check if the vector is anti-parallel to another vector.
Parameters:
-
vVec3 -
precisionNumberSet to zero for exact comparisons
Returns:
isZero
()
Returns:
bool
lerp
-
v -
t -
target
Do a linear interpolation between two vectors
mult
-
scalar -
target
Multiply the vector with a scalar
Parameters:
-
scalarNumber -
targetVec3
Returns:
negate
-
target
Make the vector point in the opposite direction.
Parameters:
-
targetVec3Optional target to save in
Returns:
norm
()
Number
Get the 2-norm (length) of the vector
Returns:
norm2
()
Number
Get the squared length of the vector
Returns:
normalize
()
Number
Normalize the vector. Note that this changes the values in the vector.
Returns:
Returns the norm of the vector
scale
-
scalar -
target
Multiply the vector with a scalar.
Parameters:
-
scalarNumber -
targetVec3
Returns:
set
-
x -
y -
z
Set the vectors' 3 elements
Parameters:
-
xNumber -
yNumber -
zNumber
Returns:
Vec3
setZero
()
Set all components of the vector to zero.
tangents
-
t1 -
t2
Compute two artificial tangents to the vector
toArray
()
Converts to an array
Returns:
Array
toString
()
Converts to a more readable format
Returns:
string
