Class MyVector3f

java.lang.Object
jme3utilities.math.MyVector3f

public final class MyVector3f extends Object
Utility methods for 3-D vectors.
  • Field Details

    • firstAxis

      public static final int firstAxis
      index of the first (X) axis
      See Also:
    • numAxes

      public static final int numAxes
      number of axes in the coordinate system
      See Also:
    • xAxis

      public static final int xAxis
      index of the X axis
      See Also:
    • yAxis

      public static final int yAxis
      index of the Y axis
      See Also:
    • zAxis

      public static final int zAxis
      index of the Z axis
      See Also:
    • lastAxis

      public static final int lastAxis
      index of the final (Z) axis
      See Also:
    • logger

      public static final Logger logger
      message logger for this class
  • Method Details

    • accumulateMaxima

      public static void accumulateMaxima(Vector3f maxima, Vector3f input)
      Accumulate maximum coordinates.
      Parameters:
      maxima - the highest coordinate so far for each axis (not null, modified)
      input - vector to compare (not null, unaffected)
    • accumulateMinima

      public static void accumulateMinima(Vector3f minima, Vector3f input)
      Accumulate minimum coordinates.
      Parameters:
      minima - the lowest coordinate so far for each axis (not null, modified)
      input - vector to compare (not null, unaffected)
    • accumulateScaled

      public static void accumulateScaled(Vector3f total, Vector3f input, float scale)
      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

      public static String describe(Vector3f vector)
      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

      public static String describeDirection(Vector3f v)
      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

      public static double dot(Vector3f vector1, Vector3f vector2)
      Determine the dot (scalar) product of 2 vectors. Unlike Vector3f.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

      public static void generateBasis(Vector3f in1, Vector3f store2, Vector3f store3)
      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

      public 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.
      Parameters:
      vector - input (not null, unaffected)
      Returns:
      true if all components are non-negative, false otherwise
    • isAllPositive

      public 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.
      Parameters:
      vector - input (not null, unaffected)
      Returns:
      true if all components are positive, false otherwise
    • isScaleIdentity

      public static boolean isScaleIdentity(Vector3f vector)
      Test for a scale identity.
      Parameters:
      vector - input (not null, unaffected)
      Returns:
      true if the vector equals Vector3f.UNIT_XYZ, false otherwise
    • isScaleUniform

      public static boolean isScaleUniform(Vector3f vector)
      Test for a uniform scaling vector.
      Parameters:
      vector - input (not null, unaffected)
      Returns:
      true if all 3 components are equal, false otherwise
    • isZero

      public static boolean isZero(Vector3f vector)
      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

      public static double lengthSquared(Vector3f vector)
      Determine the squared length of a vector. Unlike Vector3f.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

      public static Vector3f lerp(float t, Vector3f v0, Vector3f v1, Vector3f storeResult)
      Interpolate linearly between (or extrapolate linearly from) 2 vectors.

      No rounding error is introduced when v1==v2.

      Parameters:
      t - the weight given to v1
      v0 - the function value at t=0 (not null, unaffected unless it's also storeResult)
      v1 - the function value at t=1 (not null, unaffected unless it's also storeResult)
      storeResult - storage for the result (modified if not null, may be v0 or v1)
      Returns:
      the interpolated value (either storeResult or a new instance)
    • midpoint

      public static Vector3f midpoint(Vector3f vector1, Vector3f vector2, Vector3f storeResult)
      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 be vector1 or vector2)
      Returns:
      a coordinate vector (either storeResult or a new instance)
    • ne

      public static boolean ne(Vector3f v1, Vector3f v2)
      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

      public static void normalizeLocal(Vector3f input)
      Normalize the specified vector in place.
      Parameters:
      input - (not null, modified)
    • standardize

      public static Vector3f standardize(Vector3f input, Vector3f storeResult)
      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 be input)
      Returns:
      an equivalent vector without any negative zero components (either storeResult or a new instance)