Class Vector3f

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

    public class Vector3f
    extends java.lang.Object
    implements java.lang.Comparable<Vector3f>, 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 Vector3f ZERO
        Zero vector: (0,0,0)
      • UNIT_X

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

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

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

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

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

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

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

        public float X
        Vector data:
      • Y

        public float Y
      • Z

        public float Z
    • Constructor Detail

      • Vector3f

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

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

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

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

      • Angle

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

        public static void ComputeExtremes​(int iVQuantity,
                                           Vector3f[] akPoint,
                                           Vector3f rkMin,
                                           Vector3f rkMax)
        Deprecated.
        Computes the extremes: min, max for x,y,z from an array of Vector3f.
        Parameters:
        iVQuantity - the number of Vector3f in the array
        akPoint - the array of Vector3f 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,
                                           Vector3f[] akPoint,
                                           Vector3f rkMin,
                                           Vector3f rkMax)
      • GenerateComplementBasis

        public static void GenerateComplementBasis​(Vector3f rkU,
                                                   Vector3f rkV,
                                                   Vector3f 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​(Vector3f rkU,
                                                    Vector3f rkV,
                                                    Vector3f 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​(Vector3f rkU,
                                                    Vector3f rkV,
                                                    Vector3f rkW)
      • add

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

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

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

        public void Add​(float fX,
                        float fY,
                        float 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​(Vector3f rkV)
        Deprecated.
        Add the input vector to this: this = this + rkV
        Parameters:
        rkV - input vector to add to this
      • Add

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

        public float Angle​(Vector3f rkV1)
        Deprecated.
      • angle

        public float angle​(Vector3f rkV1)
      • Copy

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

        public void Cross​(Vector3f 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​(Vector3f kV1,
                          Vector3f 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 float Distance​(Vector3f 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 float distance​(Vector3f kV)
      • Div

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

        public Vector3f div​(float fScalar)
      • Div

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

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

        public float dot​(Vector3f 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​(Vector3f rkV)
        Deprecated.
        Return true if the input Vector3f is equal to this.
        Parameters:
        rkV - input vector to compare to this
        Returns:
        true if the input Vector3f is equal to this, false otherwise.
      • isEqual

        public boolean isEqual​(Vector3f rkV)
      • IsLessThan

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

        public boolean isLessThan​(Vector3f rkV)
      • Length

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

        public float length()
      • Max

        public void Max​(Vector3f 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​(Vector3f 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​(Vector3f rkV)
        Deprecated.
        Multiply the input vector to this: this = this * rkV
        Parameters:
        rkV - input vector to multiply to this
      • Mult

        public void Mult​(Vector3f rkV1,
                         Vector3f 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​(Vector3f kV)
        Deprecated.
        Set this to the negative of the input vector: this = -kV.
        Parameters:
        kV - input vector.
      • Normalize

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

        public float normalize()
      • Normalize

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

        public static float normalize​(Vector3f kV)
      • Scale

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

        public Vector3f scale​(float fScalar)
        this = this * fScalar
        Parameters:
        fScalar -
        Returns:
        this
      • Scale

        public void Scale​(float fX,
                          float fY,
                          float 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 Vector3f scale​(float fX,
                              float fY,
                              float fZ)
      • Scale

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

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

        public void ScaleAdd​(float fScalar,
                             Vector3f rkV1,
                             Vector3f 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​(float fX,
                        float fY,
                        float fZ)
        Deprecated.
        construction
        Parameters:
        fX - x-value
        fY - y-value
        fZ - z-value
      • set

        public Vector3f set​(float fX,
                            float fY,
                            float fZ)
      • SquaredDistance

        public float SquaredDistance​(Vector3f 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 float squaredDistance​(Vector3f kV)
      • SquaredLength

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

        public float squaredLength()
      • squaredRootLength

        public float squaredRootLength()
      • Sub

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

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

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

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

        public float 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​(Vector3f 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​(Vector3f kV1,
                              Vector3f 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​(Vector3f arg0,
                           Vector3f arg1)
        Sorting a list of Vector3f in order, where each element is a column when two Vector3f have equal X then the sort is by Y, then by Z.
        Parameters:
        arg0 -
        arg1 -
        Returns:
      • compareTo

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