Class Vector3d

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Vector3d>

    public class Vector3d
    extends java.lang.Object
    implements java.lang.Comparable<Vector3d>, java.io.Serializable
    3D Vector object.
    See Also:
    Serialized Form
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Serialization support
        See Also:
        Constant Field Values
      • ZERO

        public static final transient Vector3d ZERO
        Zero vector: (0,0,0)
      • UNIT_X

        public static final transient Vector3d UNIT_X
        Unit-X vector: (1,0,0)
      • UNIT_Y

        public static final transient Vector3d UNIT_Y
        Unit-Y vector: (0,1,0)
      • UNIT_Z

        public static final transient Vector3d UNIT_Z
        Unit-Z vector: (0,0,1)
      • UNIT_X_NEG

        public static final transient Vector3d UNIT_X_NEG
        negative unit-X vector: (-1,0,0)
      • UNIT_Y_NEG

        public static final transient Vector3d UNIT_Y_NEG
        negative unit-Y vector: (0,-1,0)
      • UNIT_Z_NEG

        public static final transient Vector3d UNIT_Z_NEG
        negative unit-Z vector: (0,0,-1)
      • ONE

        public static final transient Vector3d ONE
        One vector: (1,1,1)
      • X

        public double X
        Vector data:
      • Y

        public double Y
      • Z

        public double Z
    • Constructor Detail

      • Vector3d

        public Vector3d()
        construction, initialized to (0,0,0)
      • Vector3d

        public Vector3d​(double fX,
                        double fY,
                        double fZ)
        construction
        Parameters:
        fX - x-value
        fY - y-value
        fZ - z-value
      • Vector3d

        public Vector3d​(double[] afTuple)
        construction
        Parameters:
        afTuple - x,y,z values
      • Vector3d

        public Vector3d​(Vector3d rkV)
        copy construction
        Parameters:
        rkV - vector to copy.
    • Method Detail

      • Angle

        public static double Angle​(Vector3d rkV1,
                                   Vector3d rkV2)
        Deprecated.
        Parameters:
        rkV1 -
        rkV2 -
        Returns:
      • ComputeExtremes

        public static void ComputeExtremes​(int iVQuantity,
                                           Vector3d[] akPoint,
                                           Vector3d rkMin,
                                           Vector3d rkMax)
        Deprecated.
        Computes the extremes: min, max for x,y,z from an array of Vector3d.
        Parameters:
        iVQuantity - the number of Vector3d in the array
        akPoint - the array of Vector3d to compute the extremes for.
        rkMin - set to minimum (x,y,z) of all the Vectors in the array.
        rkMax - set to maximum (x,y,z) of all the Vectors in the array.
      • computeExtremes

        public static void computeExtremes​(int iVQuantity,
                                           Vector3d[] akPoint,
                                           Vector3d rkMin,
                                           Vector3d rkMax)
      • GenerateComplementBasis

        public static void GenerateComplementBasis​(Vector3d rkU,
                                                   Vector3d rkV,
                                                   Vector3d rkW)
        Deprecated.
        Input W must be a unit-length vector. The output vectors {U,V} are unit length and mutually perpendicular, and {U,V,W} is an orthonormal basis.
        Parameters:
        rkU - U
        rkV - V
        rkW - W, input and output
      • GenerateOrthonormalBasis

        public static void GenerateOrthonormalBasis​(Vector3d rkU,
                                                    Vector3d rkV,
                                                    Vector3d rkW)
        Deprecated.
        Input W must be a nonzero vector. The output is an orthonormal basis {U,V,W}. The input W is normalized by this function. If you know W is already unit length, use GenerateComplementBasis to compute U and V.
        Parameters:
        rkU - U
        rkV - V
        rkW - W, input and output
      • generateOrthonormalBasis

        public static void generateOrthonormalBasis​(Vector3d rkU,
                                                    Vector3d rkV,
                                                    Vector3d rkW)
      • add

        public Vector3d add​(double fX,
                            double fY,
                            double fZ)
        Add the inputs to this, this = this + fX,fY,fZ
        Parameters:
        fX - x-value
        fY - y-value
        fZ - z-value
      • add

        public Vector3d add​(Vector3d rkV)
        Add the input vector to this: this = this + rkV
        Parameters:
        rkV -
        Returns:
        this
      • add

        public static Vector3d add​(Vector3d rkV1,
                                   Vector3d rkV2)
        Add the two input vectors, setting this: this = rkV1 + rkV2
        Parameters:
        rkV1 - first input vector
        rkV2 - second input vector
      • Add

        public void Add​(double fX,
                        double fY,
                        double fZ)
        Deprecated.
        Add the inputs to this, this = this + fX,fY,fZ
        Parameters:
        fX - x-value
        fY - y-value
        fZ - z-value
      • Add

        public void Add​(Vector3d rkV)
        Deprecated.
        Add the input vector to this: this = this + rkV
        Parameters:
        rkV - input vector to add to this
      • Add

        public void Add​(Vector3d rkV1,
                        Vector3d rkV2)
        Deprecated.
        Add the two input vectors, setting this: this = rkV1 + rkV2
        Parameters:
        rkV1 - first input vector
        rkV2 - second input vector
      • Angle

        public double Angle​(Vector3d rkV1)
        Deprecated.
      • angle

        public double angle​(Vector3d rkV1)
      • Copy

        public void Copy​(Vector3d rkV)
        Deprecated.
        copy into this vector.
        Parameters:
        rkV - vector to copy.
      • Cross

        public void Cross​(Vector3d rkV)
        Deprecated.
        The cross products are computed using the right-handed rule. Be aware that some graphics APIs use a left-handed rule. If you have to compute a cross product with these functions and send the result to the API that expects left-handed, you will need to change sign on the vector (replace each component value c by -c). this = this ^ kV
        Parameters:
        rkV - vector to cross with this
      • Cross

        public void Cross​(Vector3d kV1,
                          Vector3d kV2)
        Deprecated.
        The cross products are computed using the right-handed rule. Be aware that some graphics APIs use a left-handed rule. If you have to compute a cross product with these functions and send the result to the API that expects left-handed, you will need to change sign on the vector (replace each component value c by -c). this = kV1 ^ kV2
        Parameters:
        kV1 - first vector
        kV2 - second vector
      • Distance

        public double Distance​(Vector3d kV)
        Deprecated.
        Compute the distance from this vector to the input vector.
        Parameters:
        kV - vector to calculate distance to.
        Returns:
        distance from this vector to the input vector.
      • distance

        public double distance​(Vector3d kV)
      • Div

        public void Div​(double fScalar)
        Deprecated.
        Divide this vector by fScalar: this = this/fScalar
        Parameters:
        fScalar - scale value
      • div

        public Vector3d div​(double fScalar)
      • Div

        public void Div​(double fScalar,
                        Vector3d kV)
        Deprecated.
        Divide the vector by fScalar, setting this: this = kV/fScalar
        Parameters:
        fScalar - scale value
        kV - input vector
      • Dot

        public double Dot​(Vector3d rkV)
        Deprecated.
        Compute dot-product of this vector with input vector:
        Returns:
        dot-product of this vector with input vector:
      • dot

        public double dot​(Vector3d rkV)
      • equals

        public boolean equals​(java.lang.Object kObject)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public void Invert()
        Deprecated.
        Invert this vector: this = 1/this;
      • IsEqual

        public boolean IsEqual​(Vector3d rkV)
        Deprecated.
        Return true if the input Vector3d is equal to this.
        Parameters:
        rkV - input vector to compare to this
        Returns:
        true if the input Vector3d is equal to this, false otherwise.
      • isEqual

        public boolean isEqual​(Vector3d rkV)
      • IsLessThan

        public boolean IsLessThan​(Vector3d rkV)
        Deprecated.
        Return true if the input Vector3d is less than to this.
        Parameters:
        rkV - input vector to compare to this
        Returns:
        true if the input Vector3d is less than to this, false otherwise.
      • isLessThan

        public boolean isLessThan​(Vector3d rkV)
      • Length

        public double Length()
        Deprecated.
        Compute length this vector:
        Returns:
        length this vector
      • length

        public double length()
      • Max

        public void Max​(Vector3d kV)
        Deprecated.
        Maximum function. Sets this to be the maximum of this and the input vector: this = max( this, kV ).
        Parameters:
        kV - input vector.
      • Min

        public void Min​(Vector3d kV)
        Deprecated.
        Minimum function. Sets this to be the minimum of this and the input vector: this = min( this, kV ).
        Parameters:
        kV - input vector.
      • Mult

        public void Mult​(Vector3d rkV)
        Deprecated.
        Multiply the input vector to this: this = this * rkV
        Parameters:
        rkV - input vector to multiply to this
      • Mult

        public void Mult​(Vector3d rkV1,
                         Vector3d rkV2)
        Deprecated.
        Multiply the two input vectors, setting this: this = rkV1 * rkV2
        Parameters:
        rkV1 - first input vector
        rkV2 - second input vector
      • Neg

        public void Neg()
        Deprecated.
        Negate this vector: this = - this.
      • Neg

        public void Neg​(Vector3d kV)
        Deprecated.
        Set this to the negative of the input vector: this = -kV.
        Parameters:
        kV - input vector.
      • Normalize

        public double Normalize()
        Deprecated.
        Normalize this vector, return original length:
        Returns:
        original length:
      • normalize

        public double normalize()
      • Normalize

        public double Normalize​(Vector3d kV)
        Deprecated.
        Normalize this vector, return original length:
        Returns:
        original length:
      • normalize

        public static double normalize​(Vector3d kV)
      • Scale

        public void Scale​(double fScalar)
        Deprecated.
        Scale this vector by input: this = this * fScalar.
        Parameters:
        fScalar - scale value
      • scale

        public Vector3d scale​(double fScalar)
        this = this * fScalar
        Parameters:
        fScalar -
        Returns:
        this
      • Scale

        public void Scale​(double fX,
                          double fY,
                          double fZ)
        Deprecated.
        Scale this vector by input: this = this * fScalar.
        Parameters:
        fX - scale X value
        fY - scale Y value
        fZ - scale Z value
      • scale

        public Vector3d scale​(double fX,
                              double fY,
                              double fZ)
      • Scale

        public void Scale​(double fScalar,
                          Vector3d rkV)
        Deprecated.
        Scale the input vector by the scalar, setting this: this = fScalar * rkV.
        Parameters:
        fScalar - scale value
        rkV - input vector
      • scale

        public static Vector3d scale​(double fScalar,
                                     Vector3d rkV)
        Parameters:
        fScalar -
        rkV -
        Returns:
        fScalar * rkV
      • ScaleAdd

        public void ScaleAdd​(double fScalar,
                             Vector3d rkV1,
                             Vector3d rkV2)
        Deprecated.
        Scale the input vector by the scalar, setting this: this = fScalar * rkV1 + rkV2.
        Parameters:
        fScalar - scale value
        rkV1 - input vector
        rkV2 - input vector
      • Set

        public void Set​(double fX,
                        double fY,
                        double fZ)
        Deprecated.
        construction
        Parameters:
        fX - x-value
        fY - y-value
        fZ - z-value
      • set

        public Vector3d set​(double fX,
                            double fY,
                            double fZ)
      • SquaredDistance

        public double SquaredDistance​(Vector3d kV)
        Deprecated.
        Compute the distance from this vector to the input vector.
        Parameters:
        kV - vector to calculate distance to.
        Returns:
        distance from this vector to the input vector.
      • squaredDistance

        public double squaredDistance​(Vector3d kV)
      • SquaredLength

        public double SquaredLength()
        Deprecated.
        Compute squared-length this vector:
        Returns:
        squared-length this vector
      • squaredLength

        public double squaredLength()
      • Sub

        public void Sub​(Vector3d rkV)
        Deprecated.
        Subtract the input vector from this: this = this - rkV
        Parameters:
        rkV - input vector to subtract from this
      • sub

        public Vector3d sub​(Vector3d rkV)
        this = this - rkV
        Parameters:
        rkV -
        Returns:
        this
      • Sub

        public void Sub​(Vector3d rkV1,
                        Vector3d rkV2)
        Deprecated.
        Subtract the two input vectors, setting this: this = rkV1 - rkV2
        Parameters:
        rkV1 - first input vector
        rkV2 - second input vector
      • Sum

        public double Sum()
        Deprecated.
        Sum the elements of the vector.
        Returns:
        vector sum
      • sum

        public double sum()
      • toString

        public java.lang.String toString()
        Returns a string representation of the vector values.
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation of the vector values.
      • UnitCross

        public void UnitCross​(Vector3d rkV)
        Deprecated.
        The cross products are computed using the right-handed rule. Be aware that some graphics APIs use a left-handed rule. If you have to compute a cross product with these functions and send the result to the API that expects left-handed, you will need to change sign on the vector (replace each component value c by -c). this = this ^ kV Normalize(this)
        Parameters:
        rkV - vector to cross with this
      • UnitCross

        public void UnitCross​(Vector3d kV1,
                              Vector3d kV2)
        Deprecated.
        The cross products are computed using the right-handed rule. Be aware that some graphics APIs use a left-handed rule. If you have to compute a cross product with these functions and send the result to the API that expects left-handed, you will need to change sign on the vector (replace each component value c by -c). this = kV1 ^ kV2 Normalize(this)
        Parameters:
        kV1 - first vector
        kV2 - second vector
      • compare

        public int compare​(Vector3d arg0,
                           Vector3d arg1)
        Sorting a list of Vector3d in order, where each element is a column when two Vector3d have equal X then the sort is by Y.
        Parameters:
        arg0 -
        arg1 -
        Returns:
      • compareTo

        public int compareTo​(Vector3d arg0)
        Specified by:
        compareTo in interface java.lang.Comparable<Vector3d>