Class Vector3D


  • public final class Vector3D
    extends java.lang.Object
    A basic 3D vector class (immutable)
    Since:
    18246
    • Field Detail

      • x

        private final double x
      • y

        private final double y
      • z

        private final double z
      • polarAngle

        private volatile double polarAngle
        The polar angle theta (inclination)
      • polarAngleCos

        private volatile double polarAngleCos
        Cosine of polar angle (angle from Z axis, AKA straight up)
      • polarAngleSin

        private volatile double polarAngleSin
        Sine of polar angle (angle from Z axis, AKA straight up)
      • azimuthalAngle

        private volatile double azimuthalAngle
        The azimuthal angle phi
      • azimuthalAngleCos

        private volatile double azimuthalAngleCos
        Cosine of azimuthal angle (angle from X axis)
      • azimuthalAngleSin

        private volatile double azimuthalAngleSin
        Sine of azimuthal angle (angle from X axis)
    • Constructor Detail

      • Vector3D

        public Vector3D​(double x,
                        double y,
                        double z)
        Create a new Vector3D object using the XYZ coordinate system
        Parameters:
        x - The x coordinate
        y - The y coordinate
        z - The z coordinate
      • Vector3D

        public Vector3D​(Vector3D.VectorType vectorType,
                        double first,
                        double second,
                        double third)
        Create a new Vector3D object. See ordering in Vector3D.VectorType.
        Parameters:
        first - The first coordinate
        second - The second coordinate
        third - The third coordinate
        vectorType - The coordinate type (determines how the other variables are treated)
    • Method Detail

      • getX

        public double getX()
        Get the x coordinate
        Returns:
        The x coordinate
      • getY

        public double getY()
        Get the y coordinate
        Returns:
        The y coordinate
      • getZ

        public double getZ()
        Get the z coordinate
        Returns:
        The z coordinate
      • getRadialDistance

        public double getRadialDistance()
        Get the radius
        Returns:
        The radius
      • getPolarAngle

        public double getPolarAngle()
        Get the polar angle (inclination)
        Returns:
        The polar angle
      • getPolarAngleCos

        public double getPolarAngleCos()
        Get the polar angle cosine (inclination)
        Returns:
        The polar angle cosine
      • getPolarAngleSin

        public double getPolarAngleSin()
        Get the polar angle sine (inclination)
        Returns:
        The polar angle sine
      • getAzimuthalAngle

        public double getAzimuthalAngle()
        Get the azimuthal angle
        Returns:
        The azimuthal angle
      • getAzimuthalAngleCos

        public double getAzimuthalAngleCos()
        Get the azimuthal angle cosine
        Returns:
        The azimuthal angle cosine
      • getAzimuthalAngleSin

        public double getAzimuthalAngleSin()
        Get the azimuthal angle sine
        Returns:
        The azimuthal angle sine
      • normalize

        public Vector3D normalize()
        Normalize the vector
        Returns:
        A normalized vector
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object