Package jme3utilities.math
Class MyVector3f
java.lang.Object
jme3utilities.math.MyVector3f
Utility methods for 3-D vectors.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
index of the first (X) axisstatic final int
index of the final (Z) axisstatic final Logger
message logger for this classstatic final int
number of axes in the coordinate systemstatic final int
index of the X axisstatic final int
index of the Y axisstatic final int
index of the Z axis -
Method Summary
Modifier and TypeMethodDescriptionstatic void
accumulateMaxima
(Vector3f maxima, Vector3f input) Accumulate maximum coordinates.static void
accumulateMinima
(Vector3f minima, Vector3f input) Accumulate minimum coordinates.static void
accumulateScaled
(Vector3f total, Vector3f input, float scale) Accumulate a linear combination of vectors.static String
Generate a textual description of a Vector3f value.static String
Generate a textual description of a direction vector.static double
Determine the dot (scalar) product of 2 vectors.static void
generateBasis
(Vector3f in1, Vector3f store2, Vector3f store3) Generate an orthonormal basis that includes the specified vector.static boolean
isAllNonNegative
(Vector3f vector) Test whether all components of a vector are all non-negative: in other words, whether it's in the first octant or the boundaries thereof.static boolean
isAllPositive
(Vector3f vector) Test whether all components of a vector are all positive: in other words, whether it's strictly inside the first octant.static boolean
isScaleIdentity
(Vector3f vector) Test for a scale identity.static boolean
isScaleUniform
(Vector3f vector) Test for a uniform scaling vector.static boolean
Test for a zero vector or translation identity.static double
lengthSquared
(Vector3f vector) Determine the squared length of a vector.static Vector3f
Interpolate linearly between (or extrapolate linearly from) 2 vectors.static Vector3f
Determine the midpoint between 2 locations.static boolean
Test whether 2 vectors are distinct, without distinguishing 0 from -0.static void
normalizeLocal
(Vector3f input) Normalize the specified vector in place.static Vector3f
standardize
(Vector3f input, Vector3f storeResult) Standardize a vector in preparation for hashing.
-
Field Details
-
firstAxis
public static final int firstAxisindex of the first (X) axis- See Also:
-
numAxes
public static final int numAxesnumber of axes in the coordinate system- See Also:
-
xAxis
public static final int xAxisindex of the X axis- See Also:
-
yAxis
public static final int yAxisindex of the Y axis- See Also:
-
zAxis
public static final int zAxisindex of the Z axis- See Also:
-
lastAxis
public static final int lastAxisindex of the final (Z) axis- See Also:
-
logger
message logger for this class
-
-
Method Details
-
accumulateMaxima
Accumulate maximum coordinates.- Parameters:
maxima
- the highest coordinate so far for each axis (not null, modified)input
- vector to compare (not null, unaffected)
-
accumulateMinima
Accumulate minimum coordinates.- Parameters:
minima
- the lowest coordinate so far for each axis (not null, modified)input
- vector to compare (not null, unaffected)
-
accumulateScaled
Accumulate a linear combination of vectors.- Parameters:
total
- sum of the scaled inputs so far (not null, modified)input
- the vector to scale and add (not null, unaffected)scale
- scale factor to apply to the input
-
describe
Generate a textual description of a Vector3f value.- Parameters:
vector
- the value to describe (may be null, unaffected)- Returns:
- a description (not null, not empty)
-
describeDirection
Generate a textual description of a direction vector.- Parameters:
v
- the value to describe (may be null, unaffected)- Returns:
- a description (not null, not empty)
-
dot
Determine the dot (scalar) product of 2 vectors. UnlikeVector3f.dot(Vector3f)
, this method returns a double-precision value for precise calculation of angles.- Parameters:
vector1
- the first input vector (not null, unaffected)vector2
- the 2nd input vector (not null, unaffected)- Returns:
- the dot product
-
generateBasis
Generate an orthonormal basis that includes the specified vector.- Parameters:
in1
- input direction for the first basis vector (not null, not zero, modified)store2
- storage for the 2nd basis vector (not null, modified)store3
- storage for the 3rd basis vector (not null, modified)
-
isAllNonNegative
Test whether all components of a vector are all non-negative: in other words, whether it's in the first octant or the boundaries thereof.- Parameters:
vector
- input (not null, unaffected)- Returns:
- true if all components are non-negative, false otherwise
-
isAllPositive
Test whether all components of a vector are all positive: in other words, whether it's strictly inside the first octant.- Parameters:
vector
- input (not null, unaffected)- Returns:
- true if all components are positive, false otherwise
-
isScaleIdentity
Test for a scale identity.- Parameters:
vector
- input (not null, unaffected)- Returns:
- true if the vector equals
Vector3f.UNIT_XYZ
, false otherwise
-
isScaleUniform
Test for a uniform scaling vector.- Parameters:
vector
- input (not null, unaffected)- Returns:
- true if all 3 components are equal, false otherwise
-
isZero
Test for a zero vector or translation identity.- Parameters:
vector
- input (not null, unaffected)- Returns:
- true if the vector equals (0,0,0), false otherwise
-
lengthSquared
Determine the squared length of a vector. UnlikeVector3f.lengthSquared()
, this method uses double-precision arithmetic to reduce the risk of overflow and returns a double-precision value for precise comparison of lengths.- Parameters:
vector
- input (not null, unaffected)- Returns:
- the squared length (≥0)
-
lerp
Interpolate linearly between (or extrapolate linearly from) 2 vectors.No rounding error is introduced when v1==v2.
- Parameters:
t
- the weight given tov1
v0
- the function value at t=0 (not null, unaffected unless it's alsostoreResult
)v1
- the function value at t=1 (not null, unaffected unless it's alsostoreResult
)storeResult
- storage for the result (modified if not null, may bev0
orv1
)- Returns:
- the interpolated value (either
storeResult
or a new instance)
-
midpoint
Determine the midpoint between 2 locations.- Parameters:
vector1
- coordinates of the first location (not null, unaffected unless it's storeResult)vector2
- coordinates of the 2nd location (not null, unaffected unless it's storeResult)storeResult
- storage for the result (modified if not null, may bevector1
orvector2
)- Returns:
- a coordinate vector (either
storeResult
or a new instance)
-
ne
Test whether 2 vectors are distinct, without distinguishing 0 from -0.- Parameters:
v1
- the first input vector (not null, unaffected)v2
- the 2nd input vector (not null, unaffected)- Returns:
- true if distinct, otherwise false
-
normalizeLocal
Normalize the specified vector in place.- Parameters:
input
- (not null, modified)
-
standardize
Standardize a vector in preparation for hashing.- Parameters:
input
- (not null, unaffected unless it's also storeResult)storeResult
- storage for the result (modified if not null, may beinput
)- Returns:
- an equivalent vector without any negative zero components (either storeResult or a new instance)
-