Clearable
, EpsilonComparable<Vector4D>
, GeometricallyComparable<Vector4D>
, GeometryObject<Vector4D>
, Settable<Vector4D>
, Transformable
, Tuple4DBasics
, Tuple4DReadOnly
, Vector4DBasics
, Vector4DReadOnly
public class Vector4D extends java.lang.Object implements Vector4DBasics, GeometryObject<Vector4D>
This version of 4D vector uses double precision fields to save the value of each component. It is meant for garbage free usage.
Constructor | Description |
---|---|
Vector4D() |
Creates a new vector and initializes it components to zero.
|
Vector4D(double[] vectorArray) |
Creates a new vector and initializes its component
x , y , z , s in
order from the given array. |
Vector4D(double x,
double y,
double z,
double s) |
Creates a new vector and initializes it with the given components.
|
Vector4D(Point3DReadOnly point3D) |
Creates a new vector and initializes it to represent the given 3D point
|
Vector4D(Vector3DReadOnly vector3D) |
Creates a new vector and initializes it to represent the given 3D vector
|
Vector4D(Tuple4DReadOnly other) |
Creates a new vector and initializes it to
other . |
Modifier and Type | Method | Description |
---|---|---|
boolean |
epsilonEquals(Vector4D other,
double epsilon) |
Tests on a per component basis if this vector is equal to the given
other to an
epsilon . |
boolean |
equals(java.lang.Object object) |
Tests if the given
object 's class is the same as this, in which case the method returns
Tuple4DReadOnly.equals(Tuple4DReadOnly) , it returns false otherwise. |
boolean |
geometricallyEquals(Vector4D other,
double epsilon) |
Tests if
this and other represent the same vector 4D to an epsilon . |
double |
getS() |
Returns the s-component of this tuple.
|
double |
getX() |
Returns the x-component of this tuple.
|
double |
getY() |
Returns the y-component of this tuple.
|
double |
getZ() |
Returns the z-component of this tuple.
|
int |
hashCode() |
Calculates and returns a hash code value from the value of each component of this 4D vector.
|
void |
set(Vector4D other) |
Sets this vector to
other . |
void |
setS(double s) |
Sets the s-component of this vector.
|
void |
setX(double x) |
Sets the x-component of this vector.
|
void |
setY(double y) |
Sets the y-component of this vector.
|
void |
setZ(double z) |
Sets the z-component of this vector.
|
java.lang.String |
toString() |
Provides a
String representation of this 4D vector as follows: (x, y, z, s). |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
absolute, containsNaN, negate, set, set, set, set, set, set, set, set, setAndAbsolute, setAndNegate, setAndNormalize, setToNaN
dot, epsilonEquals, equals, get, get, get, get, get, get, get, getElement, getElement32, getS32, getX32, getY32, getZ32, norm, normSquared
add, add, add, addS, addX, addY, addZ, applyInverseTransform, applyTransform, clipToMax, clipToMin, clipToMinMax, interpolate, interpolate, normalize, scale, scale, scaleAdd, scaleAdd, scaleSub, scaleSub, set, set, set, setAndClipToMax, setAndClipToMin, setAndClipToMinMax, setAndScale, setElement, setToZero, sub, sub, sub, subS, subX, subY, subZ
geometricallyEquals
public Vector4D()
public Vector4D(double x, double y, double z, double s)
x
- the x-component.y
- the y-component.z
- the z-component.s
- the s-component.public Vector4D(double[] vectorArray)
x
, y
, z
, s
in
order from the given array.vectorArray
- the array containing this vector's components. Not modified.public Vector4D(Tuple4DReadOnly other)
other
.other
- the tuple to copy the components from. Not modified.public Vector4D(Vector3DReadOnly vector3D)
this.xyz = vector3D
this.s = 0.0
vector3D
- the 3D vector used to set this 4D vector. Not modified.public Vector4D(Point3DReadOnly point3D)
this.xyz = point3D
this.s = 1.0
point3D
- the 3D point used to set this 4D vector. Not modified.public void set(Vector4D other)
other
.public void setX(double x)
setX
in interface Vector4DBasics
x
- the new x-component's value.public void setY(double y)
setY
in interface Vector4DBasics
y
- the new y-component's value.public void setZ(double z)
setZ
in interface Vector4DBasics
z
- the new z-component's value.public void setS(double s)
setS
in interface Vector4DBasics
s
- the new s-component's value.public double getX()
getX
in interface Tuple4DReadOnly
public double getY()
getY
in interface Tuple4DReadOnly
public double getZ()
getZ
in interface Tuple4DReadOnly
public double getS()
getS
in interface Tuple4DReadOnly
public boolean equals(java.lang.Object object)
object
's class is the same as this, in which case the method returns
Tuple4DReadOnly.equals(Tuple4DReadOnly)
, it returns false
otherwise.equals
in class java.lang.Object
object
- the object to compare against this. Not modified.true
if object
and this are exactly equal, false
otherwise.public boolean epsilonEquals(Vector4D other, double epsilon)
other
to an
epsilon
.epsilonEquals
in interface EpsilonComparable<Vector4D>
other
- the other vector to compare against this. Not modified.epsilon
- the tolerance to use when comparing each component.true
if the two tuples are equal, false
otherwise.public boolean geometricallyEquals(Vector4D other, double epsilon)
this
and other
represent the same vector 4D to an epsilon
.
Two vectors are considered geometrically equal if the length of their difference is less than or
equal to epsilon
.
Note that this.geometricallyEquals(other, epsilon) == true
does not necessarily imply
this.epsilonEquals(other, epsilon)
and vice versa.
geometricallyEquals
in interface GeometricallyComparable<Vector4D>
other
- the other vector 4D to compare against this. Not modified.epsilon
- the maximum length of the difference vector can be for the two vectors to be
considered equal.true
if the two vectors represent the same geometry, false
otherwise.public java.lang.String toString()
String
representation of this 4D vector as follows: (x, y, z, s).toString
in class java.lang.Object
String
representing this 4D vector.public int hashCode()
hashCode
in class java.lang.Object