Class Vector3d

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

    public class Vector3d
    extends java.lang.Object
    implements java.io.Serializable, Vectord<Vector3d>
    Copy of libgdx's Vector3d class using doubles for some precision calculations.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      double x
      the x-component of this vector
      static Vector3d X  
      double y
      the y-component of this vector
      static Vector3d Y  
      double z
      the z-component of this vector
      static Vector3d Z  
      static Vector3d Zero  
    • Constructor Summary

      Constructors 
      Constructor Description
      Vector3d()
      Constructs a vector at (0,0,0)
      Vector3d​(double[] values)
      Creates a vector from the given array.
      Vector3d​(double x, double y, double z)
      Creates a vector with the given components
      Vector3d​(Vector3d vector)
      Creates a vector from the given vector
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Vector3d add​(double values)
      Adds the given value to all three components of the vector.
      Vector3d add​(double... vals)
      Adds the given vector to this component
      Vector3d add​(double x, double y, double z)
      Adds the given vector to this component
      Vector3d add​(com.badlogic.gdx.math.Vector3 vector)  
      Vector3d add​(Vector3d vector)
      Adds the given vector to this vector
      double angle​(Vector3d v)
      Gets the angle in degrees between the two vectors
      double anglePrecise​(Vector3d v)
      Gets the angle in degrees between the two vectors
      Vector3d clamp​(double min, double max)
      Clamps this vector's length to given min and max values
      Vector3d cpy()  
      Vector3d crs​(double x, double y, double z)
      Sets this vector to the cross product between it and the other vector.
      Vector3d crs​(Vector3d vector)
      Sets this vector to the cross product between it and the other vector.
      static Vector3d crs​(Vector3d v, Vector3d w)
      Calculates the outer product of two given vectors v and w and returns the result as a new GVector3d.
      Vector3d div​(Vector3d vec)  
      double dot​(double x, double y, double z)
      Returns the dot product between this and the given vector.
      static double dot​(double x1, double y1, double z1, double x2, double y2, double z2)  
      double dot​(Vector3d vector)  
      double dst​(double x, double y, double z)  
      static double dst​(double x1, double y1, double z1, double x2, double y2, double z2)  
      double dst​(Vector3d vector)  
      double dst2​(double x, double y, double z)
      Returns the squared distance between this point and the given point
      static double dst2​(double x1, double y1, double z1, double x2, double y2, double z2)  
      double dst2​(Vector3d point)
      This method is faster than Vectord.dst(Vectord) because it avoids calculating a square root.
      boolean epsilonEquals​(float x, float y, float z)
      Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing
      boolean epsilonEquals​(float x, float y, float z, float epsilon)
      Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
      boolean epsilonEquals​(Vector3d other)
      Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing
      boolean epsilonEquals​(Vector3d other, double epsilon)
      Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
      boolean equals​(java.lang.Object obj)  
      com.badlogic.gdx.math.Matrix4 getMatrix​(com.badlogic.gdx.math.Matrix4 aux)
      Sets the matrix aux to a translation matrix using this vector
      Matrix4d getMatrix​(Matrix4d aux)
      Sets the given matrix to a translation matrix using this vector
      static Vector3d getUnitX()  
      static Vector3d getUnitY()  
      static Vector3d getUnitZ()  
      int hashCode()  
      boolean hasNaN()  
      boolean hasOppositeDirection​(Vector3d vector)  
      boolean hasSameDirection​(Vector3d vector)  
      boolean idt​(Vector3d vector)  
      Vector3d interpolate​(Vector3d target, double alpha, Interpolationd interpolator)
      Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation method.
      boolean isCollinear​(Vector3d other)  
      boolean isCollinear​(Vector3d other, double epsilon)  
      boolean isCollinearOpposite​(Vector3d other)  
      boolean isCollinearOpposite​(Vector3d other, double epsilon)  
      boolean isOnLine​(Vector3d other)  
      boolean isOnLine​(Vector3d other, double epsilon)  
      boolean isPerpendicular​(Vector3d vector)  
      boolean isPerpendicular​(Vector3d vector, double epsilon)  
      boolean isUnit()  
      boolean isUnit​(double margin)  
      boolean isZero()  
      boolean isZero​(double margin)  
      double len()  
      static double len​(double x, double y, double z)  
      double len2()
      This method is faster than Vectord.len() because it avoids calculating a square root.
      static double len2​(double x, double y, double z)  
      Vector3d lerp​(Vector3d target, double alpha)
      Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1].
      Vector3d limit​(double limit)
      Limits the length of this vector, based on the desired maximum length.
      Vector3d limit2​(double limit2)
      Limits the length of this vector, based on the desired maximum length squared.
      Vector3d mul​(Matrix4d matrix)
      Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.
      Vector3d mul​(Quaterniond quat)
      Multiplies the vector by the given Quaternion.
      Vector3d mul​(Vector3d vec)  
      Vector3d mul4x3​(double[] matrix)
      Left-multiplies the vector by the given 4x3 column major matrix.
      Vector3d mulAdd​(Vector3d vec, double scalar)
      First scale a supplied vector, then add it to this vector.
      Vector3d mulAdd​(Vector3d vec, Vector3d mulVec)
      First scale a supplied vector, then add it to this vector.
      Vector3d mulLeft​(com.badlogic.gdx.math.Matrix3 matrix)  
      Vector3d mulRight​(com.badlogic.gdx.math.Matrix3 matrix)  
      Vector3d nor()
      Normalizes this vector.
      Vector3d prj​(Matrix4d matrix)
      Multiplies this vector by the given matrix dividing by w, assuming the fourth (w) component of the vector is 1.
      com.badlogic.gdx.math.Vector3 put​(com.badlogic.gdx.math.Vector3 vector)  
      Vector3d put​(Vector3d vector)  
      Vector3d rot​(Matrix4d matrix)
      Multiplies this vector by the first three columns of the matrix, essentially only applying rotation and scaling.
      Vector3d rotate​(double degrees, double axisX, double axisY, double axisZ)
      Rotates this vector by the given angle in degrees around the given axis.
      Vector3d rotate​(Vector3d axis, double degrees)
      Rotates this vector by the given angle in degrees around the given axis.
      Vector3d rotateRad​(double radians, double axisX, double axisY, double axisZ)
      Rotates this vector by the given angle in radians around the given axis.
      Vector3d rotateRad​(Vector3d axis, double radians)
      Rotates this vector by the given angle in radians around the given axis.
      Vector3d rotateVectorByQuaternion​(Quaterniond q)
      Rotates this vector by a quaternion, using "vector rotation" according to (60) in LL-072.
      Vector3d scaleAdd​(double s, Vector3d v)
      Scales a given vector with a scalar and add the result to this one, i.e.
      Vector3d scl​(double scalar)
      Scales this vector by a scalar
      Vector3d scl​(double vx, double vy, double vz)
      Scales this vector by the given values
      Vector3d scl​(Vector3d other)
      Scales this vector by another vector
      Vector3d set​(double[] values)
      Sets the components from the array.
      Vector3d set​(double x, double y, double z)
      Sets the vector to the given components
      Vector3d set​(float[] values)
      Sets the components from the array.
      Vector3d set​(com.badlogic.gdx.math.Vector3 vector)  
      Vector3d set​(Vector3d vector)
      Sets this vector from the given vector
      Vector3d setFromSpherical​(double azimuthalAngle, double polarAngle)
      Sets the components from the given spherical coordinate
      Vector3d setLength​(double len)
      Sets the length of this vector.
      Vector3d setLength2​(double len2)
      Sets the length of this vector, based on the square of the desired length.
      Vector3d setToRandomDirection()
      Sets this vector to the unit vector with a random direction
      com.badlogic.gdx.math.Vector3 setVector3​(com.badlogic.gdx.math.Vector3 v)
      Returns set v to this vector by casting doubles to floats.
      Vector3d setZero()
      Sets the components of this vector to 0
      Vector3d slerp​(Vector3d target, double alpha)
      Spherically interpolates between this vector and the target vector by alpha which is in the range [0,1].
      Vector3d sub​(double value)
      Subtracts the given value from all components of this vector
      Vector3d sub​(double x, double y, double z)
      Subtracts the other vector from this vector.
      Vector3d sub​(com.badlogic.gdx.math.Vector3 a_vec)  
      Vector3d sub​(Vector3d a_vec)
      Subtracts the given vector from this vector.
      java.lang.String toString()  
      com.badlogic.gdx.math.Vector3 toVector3()
      Returns a vector3 representation of this vector by casting the doubles to floats.
      Vector3d traMul​(Matrix4d matrix)
      Multiplies the vector by the transpose of the given matrix, assuming the fourth (w) component of the vector is 1.
      Vector3d unrotate​(Matrix4d matrix)
      Multiplies this vector by the transpose of the first three columns of the matrix.
      Vector3d untransform​(Matrix4d matrix)
      Translates this vector in the direction opposite to the translation of the matrix and the multiplies this vector by the transpose of the first three columns of the matrix.
      double[] values()  
      float[] valuesf()  
      float[] valuesf​(float[] vec)  
      double x()  
      double y()  
      double z()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • x

        public double x
        the x-component of this vector
      • y

        public double y
        the y-component of this vector
      • z

        public double z
        the z-component of this vector
      • Zero

        public static final Vector3d Zero
    • Constructor Detail

      • Vector3d

        public Vector3d()
        Constructs a vector at (0,0,0)
      • Vector3d

        public Vector3d​(double x,
                        double y,
                        double z)
        Creates a vector with the given components
        Parameters:
        x - The x-component
        y - The y-component
        z - The z-component
      • Vector3d

        public Vector3d​(Vector3d vector)
        Creates a vector from the given vector
        Parameters:
        vector - The vector
      • Vector3d

        public Vector3d​(double[] values)
        Creates a vector from the given array. The array must have at least 3 elements.
        Parameters:
        values - The array
    • Method Detail

      • getUnitX

        public static Vector3d getUnitX()
      • getUnitY

        public static Vector3d getUnitY()
      • getUnitZ

        public static Vector3d getUnitZ()
      • x

        public double x()
      • y

        public double y()
      • z

        public double z()
      • set

        public Vector3d set​(double x,
                            double y,
                            double z)
        Sets the vector to the given components
        Parameters:
        x - The x-component
        y - The y-component
        z - The z-component
        Returns:
        this vector for chaining
      • set

        public Vector3d set​(Vector3d vector)
        Description copied from interface: Vectord
        Sets this vector from the given vector
        Specified by:
        set in interface Vectord<Vector3d>
        Parameters:
        vector - The vector
        Returns:
        This vector for chaining
      • set

        public Vector3d set​(com.badlogic.gdx.math.Vector3 vector)
      • put

        public com.badlogic.gdx.math.Vector3 put​(com.badlogic.gdx.math.Vector3 vector)
      • set

        public Vector3d set​(double[] values)
        Sets the components from the array. The array must have at least 3 elements
        Parameters:
        values - The array
        Returns:
        this vector for chaining
      • set

        public Vector3d set​(float[] values)
        Sets the components from the array. The array must have at least 3 elements
        Parameters:
        values - The array
        Returns:
        this vector for chaining
      • setFromSpherical

        public Vector3d setFromSpherical​(double azimuthalAngle,
                                         double polarAngle)
        Sets the components from the given spherical coordinate
        Parameters:
        azimuthalAngle - The angle between x-axis in radians [0, 2pi]
        polarAngle - The angle between z-axis in radians [0, pi]
        Returns:
        This vector for chaining
      • setToRandomDirection

        public Vector3d setToRandomDirection()
        Description copied from interface: Vectord
        Sets this vector to the unit vector with a random direction
        Specified by:
        setToRandomDirection in interface Vectord<Vector3d>
        Returns:
        This vector for chaining
      • add

        public Vector3d add​(Vector3d vector)
        Description copied from interface: Vectord
        Adds the given vector to this vector
        Specified by:
        add in interface Vectord<Vector3d>
        Parameters:
        vector - The vector
        Returns:
        This vector for chaining
      • add

        public Vector3d add​(com.badlogic.gdx.math.Vector3 vector)
      • add

        public Vector3d add​(double x,
                            double y,
                            double z)
        Adds the given vector to this component
        Parameters:
        x - The x-component of the other vector
        y - The y-component of the other vector
        z - The z-component of the other vector
        Returns:
        This vector for chaining.
      • add

        public Vector3d add​(double... vals)
        Adds the given vector to this component
        Parameters:
        vals - The 3-value double vector.
        Returns:
        This vector for chaining.
      • add

        public Vector3d add​(double values)
        Adds the given value to all three components of the vector.
        Parameters:
        values - The value
        Returns:
        This vector for chaining
      • sub

        public Vector3d sub​(Vector3d a_vec)
        Description copied from interface: Vectord
        Subtracts the given vector from this vector.
        Specified by:
        sub in interface Vectord<Vector3d>
        Parameters:
        a_vec - The vector
        Returns:
        This vector for chaining
      • sub

        public Vector3d sub​(com.badlogic.gdx.math.Vector3 a_vec)
      • sub

        public Vector3d sub​(double x,
                            double y,
                            double z)
        Subtracts the other vector from this vector.
        Parameters:
        x - The x-component of the other vector
        y - The y-component of the other vector
        z - The z-component of the other vector
        Returns:
        This vector for chaining
      • sub

        public Vector3d sub​(double value)
        Subtracts the given value from all components of this vector
        Parameters:
        value - The value
        Returns:
        This vector for chaining
      • scl

        public Vector3d scl​(double scalar)
        Description copied from interface: Vectord
        Scales this vector by a scalar
        Specified by:
        scl in interface Vectord<Vector3d>
        Parameters:
        scalar - The scalar
        Returns:
        This vector for chaining
      • scl

        public Vector3d scl​(Vector3d other)
        Description copied from interface: Vectord
        Scales this vector by another vector
        Specified by:
        scl in interface Vectord<Vector3d>
        Returns:
        This vector for chaining
      • scl

        public Vector3d scl​(double vx,
                            double vy,
                            double vz)
        Scales this vector by the given values
        Parameters:
        vx - X value
        vy - Y value
        vz - Z value
        Returns:
        This vector for chaining
      • mulAdd

        public Vector3d mulAdd​(Vector3d vec,
                               double scalar)
        Description copied from interface: Vectord
        First scale a supplied vector, then add it to this vector.
        Specified by:
        mulAdd in interface Vectord<Vector3d>
        Parameters:
        vec - addition vector
        scalar - for scaling the addition vector
      • mulAdd

        public Vector3d mulAdd​(Vector3d vec,
                               Vector3d mulVec)
        Description copied from interface: Vectord
        First scale a supplied vector, then add it to this vector.
        Specified by:
        mulAdd in interface Vectord<Vector3d>
        Parameters:
        vec - addition vector
        mulVec - vector by whose values the addition vector will be scaled
      • len

        public static double len​(double x,
                                 double y,
                                 double z)
        Returns:
        The euclidian length
      • len

        public double len()
        Specified by:
        len in interface Vectord<Vector3d>
        Returns:
        The euclidean length
      • len2

        public static double len2​(double x,
                                  double y,
                                  double z)
        Returns:
        The squared euclidian length
      • len2

        public double len2()
        Description copied from interface: Vectord
        This method is faster than Vectord.len() because it avoids calculating a square root. It is useful for comparisons, but not for getting exact lengths, as the return value is the square of the actual length.
        Specified by:
        len2 in interface Vectord<Vector3d>
        Returns:
        The squared euclidean length
      • idt

        public boolean idt​(Vector3d vector)
        Parameters:
        vector - The other vector
        Returns:
        Wether this and the other vector are equal
      • dst

        public static double dst​(double x1,
                                 double y1,
                                 double z1,
                                 double x2,
                                 double y2,
                                 double z2)
        Returns:
        The euclidian distance between the two specified vectors
      • dst

        public double dst​(Vector3d vector)
        Specified by:
        dst in interface Vectord<Vector3d>
        Parameters:
        vector - The other vector
        Returns:
        the distance between this and the other vector
      • dst

        public double dst​(double x,
                          double y,
                          double z)
        Returns:
        the distance between this point and the given point
      • dst2

        public static double dst2​(double x1,
                                  double y1,
                                  double z1,
                                  double x2,
                                  double y2,
                                  double z2)
        Returns:
        the squared distance between the given points
      • dst2

        public double dst2​(Vector3d point)
        Description copied from interface: Vectord
        This method is faster than Vectord.dst(Vectord) because it avoids calculating a square root. It is useful for comparisons, but not for getting accurate distances, as the return value is the square of the actual distance.
        Specified by:
        dst2 in interface Vectord<Vector3d>
        Parameters:
        point - The other vector
        Returns:
        the squared distance between this and the other vector
      • dst2

        public double dst2​(double x,
                           double y,
                           double z)
        Returns the squared distance between this point and the given point
        Parameters:
        x - The x-component of the other point
        y - The y-component of the other point
        z - The z-component of the other point
        Returns:
        The squared distance
      • nor

        public Vector3d nor()
        Description copied from interface: Vectord
        Normalizes this vector. Does nothing if it is zero.
        Specified by:
        nor in interface Vectord<Vector3d>
        Returns:
        This vector for chaining
      • dot

        public static double dot​(double x1,
                                 double y1,
                                 double z1,
                                 double x2,
                                 double y2,
                                 double z2)
        Returns:
        The dot product between the two vectors
      • dot

        public double dot​(Vector3d vector)
        Specified by:
        dot in interface Vectord<Vector3d>
        Parameters:
        vector - The other vector
        Returns:
        The dot product between this and the other vector
      • dot

        public double dot​(double x,
                          double y,
                          double z)
        Returns the dot product between this and the given vector.
        Parameters:
        x - The x-component of the other vector
        y - The y-component of the other vector
        z - The z-component of the other vector
        Returns:
        The dot product
      • crs

        public Vector3d crs​(Vector3d vector)
        Sets this vector to the cross product between it and the other vector.
        Parameters:
        vector - The other vector
        Returns:
        This vector for chaining
      • crs

        public static Vector3d crs​(Vector3d v,
                                   Vector3d w)
        Calculates the outer product of two given vectors v and w and returns the result as a new GVector3d.
        Parameters:
        v - left operand
        w - right operand
        Returns:
        outer product of v and w
      • crs

        public Vector3d crs​(double x,
                            double y,
                            double z)
        Sets this vector to the cross product between it and the other vector.
        Parameters:
        x - The x-component of the other vector
        y - The y-component of the other vector
        z - The z-component of the other vector
        Returns:
        This vector for chaining
      • mul4x3

        public Vector3d mul4x3​(double[] matrix)
        Left-multiplies the vector by the given 4x3 column major matrix. The matrix should be composed by a 3x3 matrix representing rotation and scale plus a 1x3 matrix representing the translation.
        Parameters:
        matrix - The matrix
        Returns:
        This vector for chaining
      • mul

        public Vector3d mul​(Matrix4d matrix)
        Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.
        Parameters:
        matrix - The matrix
        Returns:
        This vector for chaining
      • mulLeft

        public Vector3d mulLeft​(com.badlogic.gdx.math.Matrix3 matrix)
      • mulRight

        public Vector3d mulRight​(com.badlogic.gdx.math.Matrix3 matrix)
      • traMul

        public Vector3d traMul​(Matrix4d matrix)
        Multiplies the vector by the transpose of the given matrix, assuming the fourth (w) component of the vector is 1.
        Parameters:
        matrix - The matrix
        Returns:
        This vector for chaining
      • mul

        public Vector3d mul​(Quaterniond quat)
        Multiplies the vector by the given Quaternion.
        Returns:
        This vector for chaining
      • prj

        public Vector3d prj​(Matrix4d matrix)
        Multiplies this vector by the given matrix dividing by w, assuming the fourth (w) component of the vector is 1. This is mostly used to project/unproject vectors via a perspective projection matrix.
        Parameters:
        matrix - The matrix.
        Returns:
        This vector for chaining
      • rot

        public Vector3d rot​(Matrix4d matrix)
        Multiplies this vector by the first three columns of the matrix, essentially only applying rotation and scaling.
        Parameters:
        matrix - The matrix
        Returns:
        This vector for chaining
      • unrotate

        public Vector3d unrotate​(Matrix4d matrix)
        Multiplies this vector by the transpose of the first three columns of the matrix. Note: only works for translation and rotation, does not work for scaling. For those, use rot(Matrix4d) with Matrix4d.inv().
        Parameters:
        matrix - The transformation matrix
        Returns:
        The vector for chaining
      • untransform

        public Vector3d untransform​(Matrix4d matrix)
        Translates this vector in the direction opposite to the translation of the matrix and the multiplies this vector by the transpose of the first three columns of the matrix. Note: only works for translation and rotation, does not work for scaling. For those, use mul(Matrix4d) with Matrix4d.inv().
        Parameters:
        matrix - The transformation matrix
        Returns:
        The vector for chaining
      • rotate

        public Vector3d rotate​(double degrees,
                               double axisX,
                               double axisY,
                               double axisZ)
        Rotates this vector by the given angle in degrees around the given axis.
        Parameters:
        degrees - the angle in degrees
        axisX - the x-component of the axis
        axisY - the y-component of the axis
        axisZ - the z-component of the axis
        Returns:
        This vector for chaining
      • rotateRad

        public Vector3d rotateRad​(double radians,
                                  double axisX,
                                  double axisY,
                                  double axisZ)
        Rotates this vector by the given angle in radians around the given axis.
        Parameters:
        radians - the angle in radians
        axisX - the x-component of the axis
        axisY - the y-component of the axis
        axisZ - the z-component of the axis
        Returns:
        This vector for chaining
      • rotate

        public Vector3d rotate​(Vector3d axis,
                               double degrees)
        Rotates this vector by the given angle in degrees around the given axis.
        Parameters:
        axis - the axis
        degrees - the angle in degrees
        Returns:
        This vector for chaining
      • rotateRad

        public Vector3d rotateRad​(Vector3d axis,
                                  double radians)
        Rotates this vector by the given angle in radians around the given axis.
        Parameters:
        axis - the axis
        radians - the angle in radians
        Returns:
        This vector for chaining
      • getMatrix

        public com.badlogic.gdx.math.Matrix4 getMatrix​(com.badlogic.gdx.math.Matrix4 aux)
        Sets the matrix aux to a translation matrix using this vector
        Parameters:
        aux -
        Returns:
        The matrix aux
      • getMatrix

        public Matrix4d getMatrix​(Matrix4d aux)
        Sets the given matrix to a translation matrix using this vector
        Parameters:
        aux - The out matrix
        Returns:
        The matrix with the transform
      • isUnit

        public boolean isUnit()
        Specified by:
        isUnit in interface Vectord<Vector3d>
        Returns:
        Whether this vector is a unit length vector
      • isUnit

        public boolean isUnit​(double margin)
        Specified by:
        isUnit in interface Vectord<Vector3d>
        Returns:
        Whether this vector is a unit length vector within the given margin.
      • isZero

        public boolean isZero()
        Specified by:
        isZero in interface Vectord<Vector3d>
        Returns:
        Whether this vector is a zero vector
      • isZero

        public boolean isZero​(double margin)
        Specified by:
        isZero in interface Vectord<Vector3d>
        Returns:
        Whether the length of this vector is smaller than the given margin
      • isOnLine

        public boolean isOnLine​(Vector3d other,
                                double epsilon)
        Specified by:
        isOnLine in interface Vectord<Vector3d>
        Returns:
        true if this vector is in line with the other vector (either in the same or the opposite direction)
      • isOnLine

        public boolean isOnLine​(Vector3d other)
        Specified by:
        isOnLine in interface Vectord<Vector3d>
        Returns:
        true if this vector is in line with the other vector (either in the same or the opposite direction)
      • isPerpendicular

        public boolean isPerpendicular​(Vector3d vector)
        Specified by:
        isPerpendicular in interface Vectord<Vector3d>
        Returns:
        Whether this vector is perpendicular with the other vector. True if the dot product is 0.
      • isPerpendicular

        public boolean isPerpendicular​(Vector3d vector,
                                       double epsilon)
        Specified by:
        isPerpendicular in interface Vectord<Vector3d>
        epsilon - a positive small number close to zero
        Returns:
        Whether this vector is perpendicular with the other vector. True if the dot product is 0.
      • hasSameDirection

        public boolean hasSameDirection​(Vector3d vector)
        Specified by:
        hasSameDirection in interface Vectord<Vector3d>
        Returns:
        Whether this vector has similar direction compared to the other vector. True if the normalized dot product is > 0.
      • hasOppositeDirection

        public boolean hasOppositeDirection​(Vector3d vector)
        Specified by:
        hasOppositeDirection in interface Vectord<Vector3d>
        Returns:
        Whether this vector has opposite direction compared to the other vector. True if the normalized dot product is < 0.
      • lerp

        public Vector3d lerp​(Vector3d target,
                             double alpha)
        Description copied from interface: Vectord
        Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored in this vector.
        Specified by:
        lerp in interface Vectord<Vector3d>
        Parameters:
        target - The target vector
        alpha - The interpolation coefficient
        Returns:
        This vector for chaining.
      • interpolate

        public Vector3d interpolate​(Vector3d target,
                                    double alpha,
                                    Interpolationd interpolator)
        Description copied from interface: Vectord
        Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation method. the result is stored in this vector.
        Specified by:
        interpolate in interface Vectord<Vector3d>
        Parameters:
        target - The target vector
        alpha - The interpolation coefficient
        interpolator - An Interpolation object describing the used interpolation method
        Returns:
        This vector for chaining.
      • slerp

        public Vector3d slerp​(Vector3d target,
                              double alpha)
        Spherically interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored in this vector.
        Parameters:
        target - The target vector
        alpha - The interpolation coefficient
        Returns:
        This vector for chaining.
      • toString

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

        public Vector3d limit​(double limit)
        Description copied from interface: Vectord
        Limits the length of this vector, based on the desired maximum length.
        Specified by:
        limit in interface Vectord<Vector3d>
        Parameters:
        limit - desired maximum length for this vector
        Returns:
        this vector for chaining
      • limit2

        public Vector3d limit2​(double limit2)
        Description copied from interface: Vectord
        Limits the length of this vector, based on the desired maximum length squared.

        This method is slightly faster than limit().

        Specified by:
        limit2 in interface Vectord<Vector3d>
        Parameters:
        limit2 - squared desired maximum length for this vector
        Returns:
        this vector for chaining
        See Also:
        Vectord.len2()
      • setLength

        public Vector3d setLength​(double len)
        Description copied from interface: Vectord
        Sets the length of this vector. Does nothing is this vector is zero.
        Specified by:
        setLength in interface Vectord<Vector3d>
        Parameters:
        len - desired length for this vector
        Returns:
        this vector for chaining
      • setLength2

        public Vector3d setLength2​(double len2)
        Description copied from interface: Vectord
        Sets the length of this vector, based on the square of the desired length. Does nothing is this vector is zero.

        This method is slightly faster than setLength().

        Specified by:
        setLength2 in interface Vectord<Vector3d>
        Parameters:
        len2 - desired square of the length for this vector
        Returns:
        this vector for chaining
        See Also:
        Vectord.len2()
      • clamp

        public Vector3d clamp​(double min,
                              double max)
        Description copied from interface: Vectord
        Clamps this vector's length to given min and max values
        Specified by:
        clamp in interface Vectord<Vector3d>
        Parameters:
        min - Min length
        max - Max length
        Returns:
        This vector for chaining
      • values

        public double[] values()
      • valuesf

        public float[] valuesf()
      • valuesf

        public float[] valuesf​(float[] vec)
      • scaleAdd

        public Vector3d scaleAdd​(double s,
                                 Vector3d v)
        Scales a given vector with a scalar and add the result to this one, i.e. this = this + s*v.
        Parameters:
        s - scalar scaling factor
        v - vector to scale
        Returns:
        vector modified in place
      • toVector3

        public com.badlogic.gdx.math.Vector3 toVector3()
        Returns a vector3 representation of this vector by casting the doubles to floats. This creates a new object
        Returns:
        The vector3 representation of this vector3d
      • setVector3

        public com.badlogic.gdx.math.Vector3 setVector3​(com.badlogic.gdx.math.Vector3 v)
        Returns set v to this vector by casting doubles to floats.
        Returns:
        The float vector v.
      • rotateVectorByQuaternion

        public Vector3d rotateVectorByQuaternion​(Quaterniond q)
        Rotates this vector by a quaternion, using "vector rotation" according to (60) in LL-072. Both the original and the returned vectors are expressed in the same reference frame as the quaternion.
        Parameters:
        q - Quaternion defining the vector rotation.
        Returns:
        the rotated vector.
      • angle

        public double angle​(Vector3d v)
        Gets the angle in degrees between the two vectors
      • anglePrecise

        public double anglePrecise​(Vector3d v)
        Gets the angle in degrees between the two vectors
      • hasNaN

        public boolean hasNaN()
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • epsilonEquals

        public boolean epsilonEquals​(Vector3d other,
                                     double epsilon)
        Description copied from interface: Vectord
        Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
        Specified by:
        epsilonEquals in interface Vectord<Vector3d>
        Returns:
        whether the vectors have fuzzy equality.
      • epsilonEquals

        public boolean epsilonEquals​(float x,
                                     float y,
                                     float z,
                                     float epsilon)
        Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
        Returns:
        whether the vectors are the same.
      • epsilonEquals

        public boolean epsilonEquals​(Vector3d other)
        Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing
        Parameters:
        other - other vector to compare
        Returns:
        true if vector are equal, otherwise false
      • epsilonEquals

        public boolean epsilonEquals​(float x,
                                     float y,
                                     float z)
        Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing
        Parameters:
        x - x component of the other vector to compare
        y - y component of the other vector to compare
        z - z component of the other vector to compare
        Returns:
        true if vector are equal, otherwise false
      • setZero

        public Vector3d setZero()
        Description copied from interface: Vectord
        Sets the components of this vector to 0
        Specified by:
        setZero in interface Vectord<Vector3d>
        Returns:
        This vector for chaining