Modifier and Type | Method and Description |
---|---|
T |
add(T v)
Adds the given vector to this vector
|
T |
clamp(float min,
float max)
Clamps this vector's length to given min and max values
|
T |
cpy() |
float |
dot(T v) |
float |
dst(T v) |
float |
dst2(T v)
This method is faster than
dst(Vector) because it avoids calculating a square root. |
boolean |
epsilonEquals(T other,
float epsilon)
Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
|
boolean |
hasOppositeDirection(T other) |
boolean |
hasSameDirection(T other) |
T |
interpolate(T target,
float alpha,
Interpolation interpolator)
Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation
method.
|
boolean |
isCollinear(T other) |
boolean |
isCollinear(T other,
float epsilon) |
boolean |
isCollinearOpposite(T other) |
boolean |
isCollinearOpposite(T other,
float epsilon) |
boolean |
isOnLine(T other) |
boolean |
isOnLine(T other,
float epsilon) |
boolean |
isPerpendicular(T other) |
boolean |
isPerpendicular(T other,
float epsilon) |
boolean |
isUnit() |
boolean |
isUnit(float margin) |
boolean |
isZero() |
boolean |
isZero(float margin) |
float |
len() |
float |
len2()
This method is faster than
len() because it avoids calculating a square root. |
T |
lerp(T target,
float alpha)
Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1].
|
T |
limit(float limit)
Limits the length of this vector, based on the desired maximum length.
|
T |
limit2(float limit2)
Limits the length of this vector, based on the desired maximum length squared.
|
T |
mulAdd(T v,
float scalar)
First scale a supplied vector, then add it to this vector.
|
T |
mulAdd(T v,
T mulVec)
First scale a supplied vector, then add it to this vector.
|
T |
nor()
Normalizes this vector.
|
T |
scl(float scalar)
Scales this vector by a scalar
|
T |
scl(T v)
Scales this vector by another vector
|
T |
set(T v)
Sets this vector from the given vector
|
T |
setLength(float len)
Sets the length of this vector.
|
T |
setLength2(float len2)
Sets the length of this vector, based on the square of the desired length.
|
T |
setToRandomDirection()
Sets this vector to the unit vector with a random direction
|
T |
setZero()
Sets the components of this vector to 0
|
T |
sub(T v)
Subtracts the given vector from this vector.
|
T cpy()
float len()
float len2()
len()
because it avoids calculating a square root. It is useful for comparisons,
but not for getting exact lengths, as the return value is the square of the actual length.T limit(float limit)
limit
- desired maximum length for this vectorT limit2(float limit2)
limit2
- squared desired maximum length for this vectorlen2()
T setLength(float len)
len
- desired length for this vectorT setLength2(float len2)
len2
- desired square of the length for this vectorlen2()
T clamp(float min, float max)
min
- Min lengthmax
- Max lengthT set(T v)
v
- The vectorT sub(T v)
v
- The vectorT nor()
T add(T v)
v
- The vectorfloat dot(T v)
v
- The other vectorT scl(float scalar)
scalar
- The scalarfloat dst(T v)
v
- The other vectorfloat dst2(T v)
dst(Vector)
because it avoids calculating a square root. It is useful for
comparisons, but not for getting accurate distances, as the return value is the square of the actual distance.v
- The other vectorT lerp(T target, float alpha)
target
- The target vectoralpha
- The interpolation coefficientT interpolate(T target, float alpha, Interpolation interpolator)
target
- The target vectoralpha
- The interpolation coefficientinterpolator
- An Interpolation object describing the used interpolation methodT setToRandomDirection()
boolean isUnit()
boolean isUnit(float margin)
boolean isZero()
boolean isZero(float margin)
boolean isOnLine(T other, float epsilon)
boolean isOnLine(T other)
boolean isCollinear(T other, float epsilon)
isOnLine(Vector, float)
&&
hasSameDirection(Vector)
).boolean isCollinear(T other)
isOnLine(Vector)
&&
hasSameDirection(Vector)
).boolean isCollinearOpposite(T other, float epsilon)
isOnLine(Vector, float)
&&
hasOppositeDirection(Vector)
).boolean isCollinearOpposite(T other)
isOnLine(Vector)
&&
hasOppositeDirection(Vector)
).boolean isPerpendicular(T other)
boolean isPerpendicular(T other, float epsilon)
epsilon
- a positive small number close to zeroboolean hasSameDirection(T other)
boolean hasOppositeDirection(T other)
boolean epsilonEquals(T other, float epsilon)
other
- epsilon
- T mulAdd(T v, float scalar)
v
- addition vectorscalar
- for scaling the addition vectorT mulAdd(T v, T mulVec)
v
- addition vectormulVec
- vector by whose values the addition vector will be scaledT setZero()
Copyright © 2019. All rights reserved.