Class Vector3d
- java.lang.Object
-
- WildMagic.LibFoundation.Mathematics.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 Summary
Fields Modifier and Type Field Description static Vector3dONEOne vector: (1,1,1)private static longserialVersionUIDSerialization supportstatic Vector3dUNIT_XUnit-X vector: (1,0,0)static Vector3dUNIT_X_NEGnegative unit-X vector: (-1,0,0)static Vector3dUNIT_YUnit-Y vector: (0,1,0)static Vector3dUNIT_Y_NEGnegative unit-Y vector: (0,-1,0)static Vector3dUNIT_ZUnit-Z vector: (0,0,1)static Vector3dUNIT_Z_NEGnegative unit-Z vector: (0,0,-1)doubleXVector data:doubleYdoubleZstatic Vector3dZEROZero vector: (0,0,0)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector3dadd(double fX, double fY, double fZ)Add the inputs to this, this = this + fX,fY,fZVector3dadd(Vector3d rkV)Add the input vector to this: this = this + rkVstatic Vector3dadd(Vector3d rkV1, Vector3d rkV2)Add the two input vectors, setting this: this = rkV1 + rkV2doubleangle(Vector3d rkV1)static doubleangle(Vector3d rkV1, Vector3d rkV2)intcompare(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.intcompareTo(Vector3d arg0)static voidcomputeExtremes(int iVQuantity, Vector3d[] akPoint, Vector3d rkMin, Vector3d rkMax)Computes the extremes: min, max for x,y,z from an array of Vector3d.Vector3dcopy(Vector3d rkV)copy into this vector.Vector3dcross(Vector3d rkV)The cross products are computed using the right-handed rule.static Vector3dcross(Vector3d kV1, Vector3d kV2)The cross products are computed using the right-handed rule.doubledistance(Vector3d kV)Compute the distance from this vector to the input vector.Vector3ddiv(double fScalar)Divide this vector by fScalar: this = this/fScalarstatic Vector3ddiv(double fScalar, Vector3d kV)Divide the vector by fScalar, setting this: this = kV/fScalardoubledot(Vector3d rkV)Compute dot-product of this vector with input vector:booleanequals(java.lang.Object kObject)static voidgenerateComplementBasis(Vector3d rkU, Vector3d rkV, Vector3d rkW)Input W must be a unit-length vector.static voidgenerateOrthonormalBasis(Vector3d rkU, Vector3d rkV, Vector3d rkW)Input W must be a nonzero vector.inthashCode()Vector3dinvert()Invert this vector: this = 1/this;booleanisEqual(Vector3d rkV)Return true if the input Vector3d is equal to this.booleanisLessThan(Vector3d rkV)Return true if the input Vector3d is less than to this.doublelength()Compute length this vector:Vector3dmax(Vector3d kV)Maximum function.Vector3dmin(Vector3d kV)Minimum function.Vector3dmult(Vector3d rkV)Multiply the input vector to this: this = this * rkVstatic Vector3dmult(Vector3d rkV1, Vector3d rkV2)Multiply the two input vectors, setting this: this = rkV1 * rkV2Vector3dneg()Negate this vector: this = - this.static Vector3dneg(Vector3d kV)Set this to the negative of the input vector: this = -kV.doublenormalize()Normalize this vector, return original length:static doublenormalize(Vector3d kV)Normalize this vector, return original length:Vector3dscale(double fScalar)this = this * fScalarVector3dscale(double fX, double fY, double fZ)Scale this vector by input: this = this * fScalar.static Vector3dscale(double fScalar, Vector3d rkV)Vector3dscaleAdd(double fScalar, Vector3d rkV1, Vector3d rkV2)Scale the input vector by the scalar, setting this: this = fScalar * rkV1 + rkV2.Vector3dset(double fX, double fY, double fZ)constructiondoublesquaredDistance(Vector3d kV)Compute the distance from this vector to the input vector.doublesquaredLength()Compute squared-length this vector:Vector3dsub(Vector3d rkV)this = this - rkVstatic Vector3dsub(Vector3d rkV1, Vector3d rkV2)Subtract the two input vectors, setting this: this = rkV1 - rkV2doublesum()Sum the elements of the vector.java.lang.StringtoString()Returns a string representation of the vector values.Vector3dunitCross(Vector3d rkV)The cross products are computed using the right-handed rule.static Vector3dunitCross(Vector3d kV1, Vector3d kV2)The cross products are computed using the right-handed rule.
-
-
-
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-valuefY- y-valuefZ- 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
-
computeExtremes
public static void computeExtremes(int iVQuantity, Vector3d[] akPoint, Vector3d rkMin, Vector3d rkMax)Computes the extremes: min, max for x,y,z from an array of Vector3d.- Parameters:
iVQuantity- the number of Vector3d in the arrayakPoint- 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.
-
generateComplementBasis
public static void generateComplementBasis(Vector3d rkU, Vector3d rkV, Vector3d rkW)
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- UrkV- VrkW- W, input and output
-
generateOrthonormalBasis
public static void generateOrthonormalBasis(Vector3d rkU, Vector3d rkV, Vector3d rkW)
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- UrkV- VrkW- W, input and output
-
add
public Vector3d add(double fX, double fY, double fZ)
Add the inputs to this, this = this + fX,fY,fZ- Parameters:
fX- x-valuefY- y-valuefZ- 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 vectorrkV2- second input vector
-
angle
public double angle(Vector3d rkV1)
-
cross
public Vector3d cross(Vector3d rkV)
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 static Vector3d cross(Vector3d kV1, Vector3d kV2)
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 vectorkV2- second vector
-
distance
public double distance(Vector3d kV)
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.
-
div
public Vector3d div(double fScalar)
Divide this vector by fScalar: this = this/fScalar- Parameters:
fScalar- scale value
-
div
public static Vector3d div(double fScalar, Vector3d kV)
Divide the vector by fScalar, setting this: this = kV/fScalar- Parameters:
fScalar- scale valuekV- input vector
-
dot
public double dot(Vector3d rkV)
Compute dot-product of this vector with input vector:- Returns:
- dot-product of this vector with input vector:
-
equals
public boolean equals(java.lang.Object kObject)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
invert
public Vector3d invert()
Invert this vector: this = 1/this;
-
isEqual
public boolean isEqual(Vector3d rkV)
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.
-
isLessThan
public boolean isLessThan(Vector3d rkV)
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.
-
length
public double length()
Compute length this vector:- Returns:
- length this vector
-
max
public Vector3d max(Vector3d kV)
Maximum function. Sets this to be the maximum of this and the input vector: this = max( this, kV ).- Parameters:
kV- input vector.
-
min
public Vector3d min(Vector3d kV)
Minimum function. Sets this to be the minimum of this and the input vector: this = min( this, kV ).- Parameters:
kV- input vector.
-
mult
public Vector3d mult(Vector3d rkV)
Multiply the input vector to this: this = this * rkV- Parameters:
rkV- input vector to multiply to this
-
mult
public static Vector3d mult(Vector3d rkV1, Vector3d rkV2)
Multiply the two input vectors, setting this: this = rkV1 * rkV2- Parameters:
rkV1- first input vectorrkV2- second input vector
-
neg
public Vector3d neg()
Negate this vector: this = - this.
-
neg
public static Vector3d neg(Vector3d kV)
Set this to the negative of the input vector: this = -kV.- Parameters:
kV- input vector.
-
normalize
public double normalize()
Normalize this vector, return original length:- Returns:
- original length:
-
normalize
public static double normalize(Vector3d kV)
Normalize this vector, return original length:- Returns:
- original length:
-
scale
public Vector3d scale(double fScalar)
this = this * fScalar- Parameters:
fScalar-- Returns:
- this
-
scale
public Vector3d scale(double fX, double fY, double fZ)
Scale this vector by input: this = this * fScalar.- Parameters:
fX- scale X valuefY- scale Y valuefZ- scale Z value
-
scale
public static Vector3d scale(double fScalar, Vector3d rkV)
- Parameters:
fScalar-rkV-- Returns:
- fScalar * rkV
-
scaleAdd
public Vector3d scaleAdd(double fScalar, Vector3d rkV1, Vector3d rkV2)
Scale the input vector by the scalar, setting this: this = fScalar * rkV1 + rkV2.- Parameters:
fScalar- scale valuerkV1- input vectorrkV2- input vector
-
set
public Vector3d set(double fX, double fY, double fZ)
construction- Parameters:
fX- x-valuefY- y-valuefZ- z-value
-
squaredDistance
public double squaredDistance(Vector3d kV)
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.
-
squaredLength
public double squaredLength()
Compute squared-length this vector:- Returns:
- squared-length this vector
-
sub
public static Vector3d sub(Vector3d rkV1, Vector3d rkV2)
Subtract the two input vectors, setting this: this = rkV1 - rkV2- Parameters:
rkV1- first input vectorrkV2- second input vector
-
sum
public double sum()
Sum the elements of the vector.- Returns:
- vector sum
-
toString
public java.lang.String toString()
Returns a string representation of the vector values.- Overrides:
toStringin classjava.lang.Object- Returns:
- string representation of the vector values.
-
unitCross
public Vector3d unitCross(Vector3d rkV)
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 static Vector3d unitCross(Vector3d kV1, Vector3d kV2)
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 vectorkV2- 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:
-
-