Class RVec3

java.lang.Object
com.github.stephengold.joltjni.RVec3
All Implemented Interfaces:
RVec3Arg

public final class RVec3 extends Object implements RVec3Arg
A vector composed of 3 double-precision components, used to represent locations in 3-dimensional space.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiate an all-zero vector (0,0,0).
    RVec3(double x, double y, double z)
    Instantiate a vector with specified components.
    Instantiate from a single-precision vector.
  • Method Summary

    Modifier and Type
    Method
    Description
    addLocal(double addX, double addY, double addZ)
    Adds specified amounts to the vector's components and returns the (modified) current instance.
    Return the first (X) component at positional precision.
    Return the 2nd (Y) component at positional precision.
    Return the 3rd (Z) component at positional precision.
    boolean
    Test whether all 3 components are finite.
    void
    set(double x, double y, double z)
    Set all 3 components to specified values.
    static RVec3
    Create a vector with all components zero.
    Return a string representation of the vector, which is unaffected.
    float
    x()
    Return the first (X) component in single precision.
    double
    xx()
    Return the first (X) component in double precision.
    float
    y()
    Return the 2nd (Y) component in single precision.
    double
    yy()
    Return the 2nd (Y) component in double precision.
    float
    z()
    Return the 3rd (Z) component in single precision.
    double
    zz()
    Return the 3rd (Z) component in double precision.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RVec3

      public RVec3()
      Instantiate an all-zero vector (0,0,0).
    • RVec3

      public RVec3(double x, double y, double z)
      Instantiate a vector with specified components.
      Parameters:
      x - the desired X component
      y - the desired Y component
      z - the desired Z component
    • RVec3

      public RVec3(Vec3Arg vec)
      Instantiate from a single-precision vector.
      Parameters:
      vec - the vector to copy (not null, unaffected)
  • Method Details

    • addLocal

      public RVec3 addLocal(double addX, double addY, double addZ)
      Adds specified amounts to the vector's components and returns the (modified) current instance.
      Parameters:
      addX - the amount to add to the X component
      addY - the amount to add to the Y component
      addZ - the amount to add to the Z component
      Returns:
      the (modified) current instance (for chaining)
    • isFinite

      public boolean isFinite()
      Test whether all 3 components are finite.
      Returns:
      true if all are finite, otherwise false
    • set

      public void set(double x, double y, double z)
      Set all 3 components to specified values.
      Parameters:
      x - the desired X component
      y - the desired Y component
      z - the desired Z component
    • sZero

      public static RVec3 sZero()
      Create a vector with all components zero.
      Returns:
      a new vector
    • getX

      public Object getX()
      Return the first (X) component at positional precision. The vector is unaffected.
      Specified by:
      getX in interface RVec3Arg
      Returns:
      the component value
    • getY

      public Object getY()
      Return the 2nd (Y) component at positional precision. The vector is unaffected.
      Specified by:
      getY in interface RVec3Arg
      Returns:
      the component value
    • getZ

      public Object getZ()
      Return the 3rd (Z) component at positional precision. The vector is unaffected.
      Specified by:
      getZ in interface RVec3Arg
      Returns:
      the component value
    • x

      public float x()
      Return the first (X) component in single precision. The vector is unaffected.
      Specified by:
      x in interface RVec3Arg
      Returns:
      the component value
    • xx

      public double xx()
      Return the first (X) component in double precision. The vector is unaffected.
      Specified by:
      xx in interface RVec3Arg
      Returns:
      the component value
    • y

      public float y()
      Return the 2nd (Y) component in single precision. The vector is unaffected.
      Specified by:
      y in interface RVec3Arg
      Returns:
      the component value
    • yy

      public double yy()
      Return the 2nd (Y) component in double precision. The vector is unaffected.
      Specified by:
      yy in interface RVec3Arg
      Returns:
      the component value
    • z

      public float z()
      Return the 3rd (Z) component in single precision. The vector is unaffected.
      Specified by:
      z in interface RVec3Arg
      Returns:
      the component value
    • zz

      public double zz()
      Return the 3rd (Z) component in double precision. The vector is unaffected.
      Specified by:
      zz in interface RVec3Arg
      Returns:
      the component value
    • toString

      public String toString()
      Return a string representation of the vector, which is unaffected. For example, a zero vector is represented by:
       RVec3(0.0 0.0 0.0)
       
      Overrides:
      toString in class Object
      Returns:
      the string representation (not null, not empty)