Class Vector3f
- java.lang.Object
-
- WildMagic.LibFoundation.Mathematics.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 Summary
Fields Modifier and Type Field Description static Vector3fONEOne vector: (1,1,1)private static longserialVersionUIDSerialization supportstatic Vector3fUNIT_XUnit-X vector: (1,0,0)static Vector3fUNIT_X_NEGnegative unit-X vector: (-1,0,0)static Vector3fUNIT_YUnit-Y vector: (0,1,0)static Vector3fUNIT_Y_NEGnegative unit-Y vector: (0,-1,0)static Vector3fUNIT_ZUnit-Z vector: (0,0,1)static Vector3fUNIT_Z_NEGnegative unit-Z vector: (0,0,-1)floatXVector data:floatYfloatZstatic Vector3fZEROZero vector: (0,0,0)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector3fadd(float fX, float fY, float fZ)Add the inputs to this, this = this + fX,fY,fZVector3fadd(Vector3f rkV)Add the input vector to this: this = this + rkVstatic Vector3fadd(Vector3f rkV1, Vector3f rkV2)Add the two input vectors, setting this: this = rkV1 + rkV2static Vector4faddToVector4(Vector3f rkV1, Vector3f rkV2)floatangle(Vector3f rkV1)static floatangle(Vector3f rkV1, Vector3f rkV2)intcompare(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.intcompareTo(Vector3f v)static voidcomputeExtremes(int iVQuantity, Vector3f[] akPoint, Vector3f rkMin, Vector3f rkMax)Computes the extremes: min, max for x,y,z from an array of Vector3f.Vector3fcopy(Vector3f rkV)copy into this vector.Vector3fcross(Vector3f rkV)The cross products are computed using the right-handed rule.static Vector3fcross(Vector3f kV1, Vector3f kV2)The cross products are computed using the right-handed rule.floatdistance(Vector3f kV)Compute the distance from this vector to the input vector.Vector3fdiv(float fScalar)Divide this vector by fScalar: this = this/fScalarstatic Vector3fdiv(float fScalar, Vector3f kV)Divide the vector by fScalar, setting this: this = kV/fScalarfloatdot(Vector3f rkV)Compute dot-product of this vector with input vector:booleanequals(java.lang.Object kObject)static voidgenerateComplementBasis(Vector3f rkU, Vector3f rkV, Vector3f rkW)Input W must be a unit-length vector.static voidgenerateOrthonormalBasis(Vector3f rkU, Vector3f rkV, Vector3f rkW)Input W must be a nonzero vector.inthashCode()Vector3finvert()Invert this vector: this = 1/this;booleanisEqual(Vector3f rkV)Return true if the input Vector3f is equal to this.booleanisLessThan(Vector3f rkV)Return true if the input Vector3f is less than to this.floatlength()Compute length this vector:Vector3fmax(Vector3f kV)Maximum function.static Vector3fMidPoint(Vector3f kP0, Vector3f kP1)Vector3fmin(Vector3f kV)Minimum function.Vector3fmult(Vector3f rkV)Multiply the input vector to this: this = this * rkVstatic Vector3fmult(Vector3f rkV1, Vector3f rkV2)Multiply the two input vectors, setting this: this = rkV1 * rkV2static Vector3fmult(Vector4f rkV1, Vector3f rkV2)Vector3fneg()Negate this vector: this = - this.static Vector3fneg(Vector3f kV)Set this to the negative of the input vector: this = -kV.floatnormalize()Normalize this vector, return original length:static floatnormalize(Vector3f kV)Normalize this vector, return original length:Vector3fscale(float fScalar)this = this * fScalarVector3fscale(float fX, float fY, float fZ)Scale this vector by input: this = this * fScalar.static Vector3fscale(float fScalar, Vector3f rkV)static Vector3fscale(float fScalar, Vector4f rkV)Vector3fscaleAdd(float fScalar, Vector3f rkV1, Vector3f rkV2)Scale the input vector by the scalar, setting this: this = fScalar * rkV1 + rkV2.static Vector3fscaleAddS(float fScalar, Vector3f rkV1, Vector3f rkV2)Vector3fset(float fX, float fY, float fZ)constructionfloatsquaredDistance(Vector3f kV)Compute the distance from this vector to the input vector.floatsquaredLength()Compute squared-length this vector:floatsquaredRootLength()Vector3fsub(Vector3f rkV)this = this - rkVstatic Vector3fsub(Vector3f rkV1, Vector3f rkV2)Subtract the two input vectors, setting this: this = rkV1 - rkV2floatsum()Sum the elements of the vector.java.lang.StringtoString()Returns a string representation of the vector values.Vector3funitCross(Vector3f rkV)The cross products are computed using the right-handed rule.static Vector3funitCross(Vector3f kV1, Vector3f 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 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-valuefY- y-valuefZ- 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
-
computeExtremes
public static void computeExtremes(int iVQuantity, Vector3f[] akPoint, Vector3f rkMin, Vector3f rkMax)Computes the extremes: min, max for x,y,z from an array of Vector3f.- Parameters:
iVQuantity- the number of Vector3f in the arrayakPoint- 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.
-
generateComplementBasis
public static void generateComplementBasis(Vector3f rkU, Vector3f rkV, Vector3f 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(Vector3f rkU, Vector3f rkV, Vector3f 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 Vector3f add(float fX, float fY, float fZ)
Add the inputs to this, this = this + fX,fY,fZ- Parameters:
fX- x-valuefY- y-valuefZ- 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 vectorrkV2- second input vector
-
angle
public float angle(Vector3f rkV1)
-
cross
public Vector3f cross(Vector3f 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 Vector3f cross(Vector3f kV1, Vector3f 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 float distance(Vector3f 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 Vector3f div(float fScalar)
Divide this vector by fScalar: this = this/fScalar- Parameters:
fScalar- scale value
-
div
public static Vector3f div(float fScalar, Vector3f kV)
Divide the vector by fScalar, setting this: this = kV/fScalar- Parameters:
fScalar- scale valuekV- input vector
-
dot
public float dot(Vector3f 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 Vector3f invert()
Invert this vector: this = 1/this;
-
isEqual
public boolean isEqual(Vector3f rkV)
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.
-
isLessThan
public boolean isLessThan(Vector3f rkV)
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.
-
length
public float length()
Compute length this vector:- Returns:
- length this vector
-
max
public Vector3f max(Vector3f 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 Vector3f min(Vector3f 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 Vector3f mult(Vector3f rkV)
Multiply the input vector to this: this = this * rkV- Parameters:
rkV- input vector to multiply to this
-
mult
public static Vector3f mult(Vector3f rkV1, Vector3f rkV2)
Multiply the two input vectors, setting this: this = rkV1 * rkV2- Parameters:
rkV1- first input vectorrkV2- second input vector
-
neg
public Vector3f neg()
Negate this vector: this = - this.
-
neg
public static Vector3f neg(Vector3f kV)
Set this to the negative of the input vector: this = -kV.- Parameters:
kV- input vector.
-
normalize
public float normalize()
Normalize this vector, return original length:- Returns:
- original length:
-
normalize
public static float normalize(Vector3f kV)
Normalize this vector, return original length:- Returns:
- original length:
-
scale
public Vector3f scale(float fScalar)
this = this * fScalar- Parameters:
fScalar-- Returns:
- this
-
scale
public Vector3f scale(float fX, float fY, float fZ)
Scale this vector by input: this = this * fScalar.- Parameters:
fX- scale X valuefY- scale Y valuefZ- scale Z value
-
scale
public static Vector3f scale(float fScalar, Vector3f rkV)
- Parameters:
fScalar-rkV-- Returns:
- fScalar * rkV
-
scaleAdd
public Vector3f scaleAdd(float fScalar, Vector3f rkV1, Vector3f rkV2)
Scale the input vector by the scalar, setting this: this = fScalar * rkV1 + rkV2.- Parameters:
fScalar- scale valuerkV1- input vectorrkV2- input vector
-
set
public Vector3f set(float fX, float fY, float fZ)
construction- Parameters:
fX- x-valuefY- y-valuefZ- z-value
-
squaredDistance
public float squaredDistance(Vector3f 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 float squaredLength()
Compute squared-length this vector:- Returns:
- squared-length this vector
-
squaredRootLength
public float squaredRootLength()
-
sub
public static Vector3f sub(Vector3f rkV1, Vector3f rkV2)
Subtract the two input vectors, setting this: this = rkV1 - rkV2- Parameters:
rkV1- first input vectorrkV2- second input vector
-
sum
public float 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 Vector3f unitCross(Vector3f 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 Vector3f unitCross(Vector3f kV1, Vector3f 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(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:
-
-