Package jme3utilities.math
Class MyVector3f
java.lang.Object
jme3utilities.math.MyVector3f
Utility methods for 3-D vectors.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intindex of the first (X) axisstatic final intindex of the final (Z) axisstatic final Loggermessage logger for this classstatic final intnumber of axes in the coordinate systemstatic final intindex of the X axisstatic final intindex of the Y axisstatic final intindex of the Z axis -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaccumulateMaxima(Vector3f maxima, Vector3f input) Accumulate maximum coordinates.static voidaccumulateMinima(Vector3f minima, Vector3f input) Accumulate minimum coordinates.static voidaccumulateScaled(Vector3f total, Vector3f input, float scale) Accumulate a linear combination of vectors.static StringGenerate a textual description of a Vector3f value.static StringGenerate a textual description of a direction vector.static doubleDetermine the dot (scalar) product of 2 vectors.static voidgenerateBasis(Vector3f in1, Vector3f store2, Vector3f store3) Generate an orthonormal basis that includes the specified vector.static booleanisAllNonNegative(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 booleanisAllPositive(Vector3f vector) Test whether all components of a vector are all positive: in other words, whether it's strictly inside the first octant.static booleanisScaleIdentity(Vector3f vector) Test for a scale identity.static booleanisScaleUniform(Vector3f vector) Test for a uniform scaling vector.static booleanTest for a zero vector or translation identity.static doublelengthSquared(Vector3f vector) Determine the squared length of a vector.static Vector3fInterpolate linearly between (or extrapolate linearly from) 2 vectors.static Vector3fDetermine the midpoint between 2 locations.static booleanTest whether 2 vectors are distinct, without distinguishing 0 from -0.static voidnormalizeLocal(Vector3f input) Normalize the specified vector in place.static Vector3fstandardize(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 tov1v0- 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 bev0orv1)- Returns:
- the interpolated value (either
storeResultor 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 bevector1orvector2)- Returns:
- a coordinate vector (either
storeResultor 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)
-