Clearable, Transformable, Tuple4DBasics, Tuple4DReadOnly, Vector4DReadOnlyVector4D, Vector4D32public interface Vector4DBasics extends Vector4DReadOnly, Tuple4DBasics
When describing a 4D tuple, its 4 components are often gathered in two groups: the scalar part
s and the vector part (x, y, z).
Note on the difference between applying a 3D transform on a quaternion and a 4D vector:
s
remains unchanged. The vector part (x, y, z) is scaled and rotated, and
translated by s times the translation part of the transform. Note that for s = 0,
a 4D vector behaves as a 3D vector, and for s = 1 it behaves as a 3D point.
| Modifier and Type | Method | Description |
|---|---|---|
default void |
add(double x,
double y,
double z,
double s) |
Adds the given (
x, y, z, s)-tuple to this vector. |
default void |
add(Tuple4DReadOnly tupleReadOnly) |
Adds the given tuple to this vector.
|
default void |
add(Tuple4DReadOnly tuple1,
Tuple4DReadOnly tuple2) |
Sets this vector to the sum of the two given tuples.
|
default void |
addS(double s) |
Adds the given
s to this vector's s-component. |
default void |
addX(double x) |
Adds the given
x to this vector's x-component. |
default void |
addY(double y) |
Adds the given
y to this vector's y-component. |
default void |
addZ(double z) |
Adds the given
z to this vector's z-component. |
default void |
applyInverseTransform(Transform transform) |
Performs the inverse the transform on the vector part (x, y, z) of this vector as a 3D vector
and translates it by
s times the translation part of the transform. |
default void |
applyTransform(Transform transform) |
Transforms the vector part (x, y, z) of this vector as a 3D vector and translates it by
s times the translation part of the transform. |
default void |
clipToMax(double max) |
Clips each component of this vector to a maximum value
max. |
default void |
clipToMin(double min) |
Clips each component of this vector to a minimum value
min. |
default void |
clipToMinMax(double min,
double max) |
Clips each component of this vector to a minimum value
min and a maximum value
max. |
default void |
interpolate(Tuple4DReadOnly tupleReadOnly,
double alpha) |
Performs a linear interpolation from this vector to
tupleReadOnly given the percentage
alpha. |
default void |
interpolate(Tuple4DReadOnly tuple1,
Tuple4DReadOnly tuple2,
double alpha) |
Performs a linear interpolation from
tuple1 to tuple2 given the percentage
alpha. |
default void |
normalize() |
Normalizes this tuple such that its norm is equal to 1 after calling this method and its
direction remains unchanged.
|
default void |
scale(double scalar) |
Scales the components of this vector by the given
scalar. |
default void |
scale(double scalarX,
double scalarY,
double scalarZ,
double scalarS) |
Scales independently each component of this vector.
|
default void |
scaleAdd(double scalar,
Tuple4DReadOnly tupleReadOnly) |
Scales this vector and adds
tupleReadOnly. |
default void |
scaleAdd(double scalar,
Tuple4DReadOnly tuple1,
Tuple4DReadOnly tuple2) |
Sets this vector to the sum of
tuple1 scaled and tuple2. |
default void |
scaleSub(double scalar,
Tuple4DReadOnly tupleReadOnly) |
Scales this vector and subtracts
tupleReadOnly. |
default void |
scaleSub(double scalar,
Tuple4DReadOnly tuple1,
Tuple4DReadOnly tuple2) |
Sets this vector to the difference of
tuple1 scaled and tuple2. |
default void |
set(double x,
double y,
double z,
double s) |
Sets this tuple's components to
x, y, z, and s. |
default void |
set(Point3DReadOnly point3D) |
Sets this 4D vector to represent the given 3D point
|
default void |
set(Vector3DReadOnly vector3D) |
Sets this 4D vector to represent the given 3D vector
|
default void |
setAndClipToMax(double max,
Tuple4DReadOnly tupleReadOnly) |
Sets this vector to
tupleReadOnly and then calls clipToMax(double). |
default void |
setAndClipToMin(double min,
Tuple4DReadOnly tupleReadOnly) |
Sets this vector to
tupleReadOnly and then calls clipToMin(double). |
default void |
setAndClipToMinMax(double min,
double max,
Tuple4DReadOnly tupleReadOnly) |
Sets this vector to
tupleReadOnly and then calls
clipToMinMax(double, double). |
default void |
setAndScale(double scalar,
Tuple4DReadOnly tupleReadOnly) |
Sets this vector to
tupleReadOnly and then scales it scale(double). |
default void |
setElement(int index,
double value) |
Selects a component of this vector based on
index and sets it to value. |
void |
setS(double s) |
Sets the s-component of this vector.
|
default void |
setToZero() |
Sets all the components of this vector to zero.
|
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.
|
default void |
sub(double x,
double y,
double z,
double s) |
Subtracts the given (
x, y, z, s)-tuple to this vector. |
default void |
sub(Tuple4DReadOnly tupleReadOnly) |
Subtracts the given tuple to this vector.
|
default void |
sub(Tuple4DReadOnly tuple1,
Tuple4DReadOnly tuple2) |
Sets this vector to the difference of the two given tuples.
|
default void |
subS(double s) |
Subtracts the given
s to this vector's s-component. |
default void |
subX(double x) |
Subtracts the given
x to this vector's x-component. |
default void |
subY(double y) |
Subtracts the given
y to this vector's y-component. |
default void |
subZ(double z) |
Subtracts the given
z to this vector's z-component. |
absolute, containsNaN, negate, set, set, set, set, set, set, set, set, setAndAbsolute, setAndNegate, setAndNormalize, setToNaNdot, epsilonEquals, equals, get, get, get, get, get, get, get, getElement, getElement32, getS, getS32, getX, getX32, getY, getY32, getZ, getZ32, norm, normSquaredgeometricallyEqualsvoid setX(double x)
x - the new x-component's value.void setY(double y)
y - the new y-component's value.void setZ(double z)
z - the new z-component's value.void setS(double s)
s - the new s-component's value.default void setToZero()
default void normalize()
Edge cases:
Double.NaN, this method is ineffective.
normalize in interface Tuple4DBasicsdefault void clipToMax(double max)
max.max - the maximum value for each component.default void clipToMin(double min)
min.min - the minimum value for each component.default void clipToMinMax(double min,
double max)
min and a maximum value
max.min - the minimum value for each component.max - the maximum value for each component.default void setElement(int index,
double value)
index and sets it to value.
For an index value going from 0 up to 3, the corresponding components are x,
y, z, and s, respectively.
index - the index of the component to set.value - the new value of the selected component.java.lang.IndexOutOfBoundsException - if index ∉ [0, 3].default void set(double x,
double y,
double z,
double s)
x, y, z, and s.set in interface Tuple4DBasicsx - the new value for the x-component of this tuple.y - the new value for the y-component of this tuple.z - the new value for the z-component of this tuple.s - the new value for the s-component of this tuple.default void set(Vector3DReadOnly vector3D)
this.xyz = vector3D
this.s = 0.0
vector3D - the 3D vector used to set this 4D vector. Not modified.default void set(Point3DReadOnly point3D)
this.xyz = point3D
this.s = 1.0
point3D - the 3D point used to set this 4D vector. Not modified.default void setAndScale(double scalar,
Tuple4DReadOnly tupleReadOnly)
tupleReadOnly and then scales it scale(double).scalar - the scale factor to use on this tuple.tupleReadOnly - the tuple to copy the values from. Not modified.default void setAndClipToMax(double max,
Tuple4DReadOnly tupleReadOnly)
tupleReadOnly and then calls clipToMax(double).max - the maximum value for each component of this tuple.tupleReadOnly - the tuple to copy the values from. Not modified.default void setAndClipToMin(double min,
Tuple4DReadOnly tupleReadOnly)
tupleReadOnly and then calls clipToMin(double).min - the minimum value for each component of this tuple.tupleReadOnly - the tuple to copy the values from. Not modified.default void setAndClipToMinMax(double min,
double max,
Tuple4DReadOnly tupleReadOnly)
tupleReadOnly and then calls
clipToMinMax(double, double).min - the minimum value for each component of this tuple.max - the maximum value for each component of this tuple.tupleReadOnly - the tuple to copy the values from. Not modified.default void addX(double x)
x to this vector's x-component.x - the value to add.default void addY(double y)
y to this vector's y-component.y - the value to add.default void addZ(double z)
z to this vector's z-component.z - the value to add.default void addS(double s)
s to this vector's s-component.s - the value to add.default void add(double x,
double y,
double z,
double s)
x, y, z, s)-tuple to this vector.
this = this + (x, y, z, s)
x - the value to add to the x-component of this vector.y - the value to add to the y-component of this vector.z - the value to add to the z-component of this vector.s - the value to add to the s-component of this vector.default void add(Tuple4DReadOnly tupleReadOnly)
this = this + tupleReadOnly
tupleReadOnly - the tuple to add to this vector.default void add(Tuple4DReadOnly tuple1, Tuple4DReadOnly tuple2)
this = tuple1 + tuple2
tuple1 - the first tuple to sum. Not modified.tuple2 - the second tuple to sum. Not modified.default void subX(double x)
x to this vector's x-component.x - the value to add.default void subY(double y)
y to this vector's y-component.y - the value to add.default void subZ(double z)
z to this vector's z-component.z - the value to add.default void subS(double s)
s to this vector's s-component.s - the value to add.default void sub(double x,
double y,
double z,
double s)
x, y, z, s)-tuple to this vector.
this = this - (x, y, z, s)
x - the value to add to the x-component of this vector.y - the value to add to the y-component of this vector.z - the value to add to the z-component of this vector.s - the value to add to the s-component of this vector.default void sub(Tuple4DReadOnly tupleReadOnly)
this = this - tupleReadOnly
tupleReadOnly - the tuple to subtract to this vector.default void sub(Tuple4DReadOnly tuple1, Tuple4DReadOnly tuple2)
this = tuple1 - tuple2
tuple1 - the first tuple. Not modified.tuple2 - the second tuple to subtract to tuple1. Not modified.default void scale(double scalar)
scalar.
this = scalar * this
scalar - the scale factor to use.default void scale(double scalarX,
double scalarY,
double scalarZ,
double scalarS)
/ this.x \ / scalarX * this.x \ | this.y | = | scalarY * this.y | | this.z | | scalarZ * this.z | \ this.s / \ scalarS * this.s /
scalarX - the scalar factor to use on the x-component of this vector.scalarY - the scalar factor to use on the y-component of this vector.scalarZ - the scalar factor to use on the z-component of this vector.scalarS - the scalar factor to use on the s-component of this vector.default void scaleAdd(double scalar,
Tuple4DReadOnly tupleReadOnly)
tupleReadOnly.
this = scalar * this + tupleReadOnly
scalar - the scale factor to use.tupleReadOnly - the tuple to add to this. Not modified.default void scaleAdd(double scalar,
Tuple4DReadOnly tuple1,
Tuple4DReadOnly tuple2)
tuple1 scaled and tuple2.
this = scalar * tuple1 + tuple2
scalar - the scale factor to use on tuple1.tuple1 - the first tuple of the sum. Not modified.tuple2 - the second tuple of the sum. Not modified.default void scaleSub(double scalar,
Tuple4DReadOnly tupleReadOnly)
tupleReadOnly.
this = scalar * this - tupleReadOnly
scalar - the scale factor to use.tupleReadOnly - the tuple to subtract to this. Not modified.default void scaleSub(double scalar,
Tuple4DReadOnly tuple1,
Tuple4DReadOnly tuple2)
tuple1 scaled and tuple2.
this = scalar * tuple1 - tuple2
scalar - the scale factor to use on tuple1.tuple1 - the first tuple of the difference. Not modified.tuple2 - the second tuple of the difference. Not modified.default void interpolate(Tuple4DReadOnly tupleReadOnly, double alpha)
tupleReadOnly given the percentage
alpha.
this = (1.0 - alpha) * this + alpha * tupleReadOnly
tupleReadOnly - the tuple used for the interpolation. Not modified.alpha - the percentage used for the interpolation. A value of 0 will result in not
modifying this vector, while a value of 1 is equivalent to setting this vector to
tupleReadOnly.default void interpolate(Tuple4DReadOnly tuple1, Tuple4DReadOnly tuple2, double alpha)
tuple1 to tuple2 given the percentage
alpha.
this = (1.0 - alpha) * tuple1 + alpha * tuple2
tuple1 - the first tuple used in the interpolation. Not modified.tuple2 - the second tuple used in the interpolation. Not modified.alpha - the percentage to use for the interpolation. A value of 0 will result in setting
this vector to tuple1, while a value of 1 is equivalent to setting this
vector to tuple2.default void applyTransform(Transform transform)
s times the translation part of the transform. The scalar part (s) remains unchanged.
Note that for s = 0, a 4D vector behaves as a 3D vector, and for s = 1 it
behaves as a 3D point.
RigidBodyTransform rotates then translates a vector.
QuaternionBasedTransform rotates then translates a vector.
AffineTransform scales, rotates, then translates a vector.
applyTransform in interface Transformabletransform - the geometric transform to apply on this vector. Not modified.default void applyInverseTransform(Transform transform)
s times the translation part of the transform. The scalar part
(s) remains unchanged.
Note that for s = 0, a 4D vector behaves as a 3D vector, and for s = 1 it
behaves as a 3D point.
RigidBodyTransform rotates then translates a vector.
QuaternionBasedTransform rotates then translates a vector.
AffineTransform scales, rotates, then translates a vector.
applyInverseTransform in interface Transformabletransform - the geometric transform to apply on this vector. Not modified.