Clearable
, Transformable
, Tuple2DReadOnly
Point2DBasics
, Vector2DBasics
Point2D
, Point2D32
, Vector2D
, Vector2D32
public interface Tuple2DBasics extends Tuple2DReadOnly, Clearable, Transformable
A tuple is an abstract geometry object holding onto the common math between a 2D point and vector.
Although a point and vector hold onto the same type of information, the distinction is made between them as they represent different geometry objects and are typically not handled the same way:
Modifier and Type | Method | Description |
---|---|---|
default void |
absolute() |
Sets each component of this tuple to its absolute value.
|
default void |
add(double x,
double y) |
Adds the given (
x , y )-tuple to this tuple. |
default void |
add(Tuple2DReadOnly other) |
Adds the given tuple to this tuple.
|
default void |
add(Tuple2DReadOnly tuple1,
Tuple2DReadOnly tuple2) |
Sets this tuple to the sum of the two given tuples.
|
default void |
addX(double x) |
Adds the given
x to this tuple's x-component. |
default void |
addY(double y) |
Adds the given
y to this tuple's y-component. |
default void |
applyInverseTransform(Transform transform) |
Transforms this tuple by the inverse of the given
transform . |
void |
applyInverseTransform(Transform transform,
boolean checkIfTransformInXYPlane) |
Transforms this tuple by the inverse of the given
transform . |
default void |
applyTransform(Transform transform) |
Transforms this tuple by the given
transform . |
void |
applyTransform(Transform transform,
boolean checkIfTransformInXYPlane) |
Transforms this tuple by the given
transform . |
default void |
clipToMax(double max) |
Clips each component of this tuple to a maximum value
max . |
default void |
clipToMin(double min) |
Clips each component of this tuple to a minimum value
min . |
default void |
clipToMinMax(double min,
double max) |
Clips each component of this tuple to a minimum value
min and a maximum value
max . |
default boolean |
containsNaN() |
Tests if this tuple contains a
Double.NaN . |
default void |
interpolate(Tuple2DReadOnly other,
double alpha) |
Performs a linear interpolation from this tuple to
other given the percentage
alpha . |
default void |
interpolate(Tuple2DReadOnly tuple1,
Tuple2DReadOnly tuple2,
double alpha) |
Performs a linear interpolation from
tuple1 to tuple2 given the percentage
alpha . |
default void |
negate() |
Changes the sign of each component of this tuple.
|
default void |
scale(double scalar) |
Scales the components of this tuple by the given
scalar . |
default void |
scale(double scalarX,
double scalarY) |
Scales independently each component of this tuple.
|
default void |
scaleAdd(double scalar,
Tuple2DReadOnly other) |
Scales this tuple and adds
other . |
default void |
scaleAdd(double scalar,
Tuple2DReadOnly tuple1,
Tuple2DReadOnly tuple2) |
Sets this tuple to the sum of
tuple1 scaled and tuple2 . |
default void |
scaleSub(double scalar,
Tuple2DReadOnly other) |
Scales this tuple and subtracts
other . |
default void |
scaleSub(double scalar,
Tuple2DReadOnly tuple1,
Tuple2DReadOnly tuple2) |
Sets this tuple to the difference of
tuple1 scaled and tuple2 . |
default void |
set(double[] tupleArray) |
Sets this tuple's components
x , y in order from the given array
tupleArray . |
default void |
set(double x,
double y) |
Sets this tuple's components to
x and y . |
default void |
set(float[] tupleArray) |
Sets this tuple's components
x , y in order from the given array
tupleArray . |
default void |
set(int startIndex,
double[] tupleArray) |
Sets this tuple's components
x , y in order from the given array
tupleArray . |
default void |
set(int startIndex,
float[] tupleArray) |
Sets this tuple's components
x , y in order from the given array
tupleArray . |
default void |
set(int startRow,
int column,
org.ejml.data.DenseMatrix64F matrix) |
Sets this tuple's components
x , y in order from the given matrix starting to
read from startRow at the column index column . |
default void |
set(int startRow,
org.ejml.data.DenseMatrix64F matrix) |
Sets this tuple's components
x , y in order from the given column vector
starting to read from startRow . |
default void |
set(org.ejml.data.DenseMatrix64F matrix) |
Sets this tuple's components
x , y in order from the given column vector
starting to read from its first row index. |
default void |
set(Tuple2DReadOnly other) |
Sets this tuple to
other . |
default void |
set(Tuple3DReadOnly tuple3DReadOnly) |
Sets this tuple with the x and y components of the given
tuple3DReadOnly |
default void |
setAndAbsolute(Tuple2DReadOnly other) |
Sets this tuple to
other and then calls absolute() . |
default void |
setAndClipToMax(double max,
Tuple2DReadOnly other) |
Sets this tuple to
other and then calls clipToMax(double) . |
default void |
setAndClipToMin(double min,
Tuple2DReadOnly other) |
Sets this tuple to
other and then calls clipToMin(double) . |
default void |
setAndClipToMinMax(double min,
double max,
Tuple2DReadOnly other) |
Sets this tuple to
other and then calls clipToMinMax(double, double) . |
default void |
setAndNegate(Tuple2DReadOnly other) |
Sets this tuple to
other and then calls negate() . |
default void |
setAndScale(double scalar,
Tuple2DReadOnly other) |
Sets this tuple to
other and then scales it scale(double) . |
default void |
setElement(int index,
double value) |
Selects a component of this tuple based on
index and sets it to value . |
default void |
setToNaN() |
Sets all the components of this tuple to
Double.NaN . |
default void |
setToZero() |
Sets all the components of this tuple to zero.
|
void |
setX(double x) |
Sets the x-component of this tuple.
|
void |
setY(double y) |
Sets the y-component of this tuple.
|
default void |
sub(double x,
double y) |
Subtracts the given (
x , y )-tuple to this tuple. |
default void |
sub(Tuple2DReadOnly tupleReadOnly) |
Subtracts the given tuple to this tuple.
|
default void |
sub(Tuple2DReadOnly tuple1,
Tuple2DReadOnly tuple2) |
Sets this tuple to the difference of the two given tuples.
|
default void |
subX(double x) |
Subtracts the given
x to this tuple's x-component. |
default void |
subY(double y) |
Subtracts the given
y to this tuple's y-component. |
epsilonEquals, equals, get, get, get, get, get, get, get, getElement, getElement32, getX, getX32, getY, getY32
void setX(double x)
x
- the new x-component's value.void setY(double y)
y
- the new y-component's value.default void setToZero()
default void setToNaN()
Double.NaN
.default boolean containsNaN()
Double.NaN
.containsNaN
in interface Clearable
containsNaN
in interface Tuple2DReadOnly
true
if this tuple contains a Double.NaN
, false
otherwise.default void absolute()
default void negate()
default 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
of 0, the corresponding component is x
, while for 1 it is
y
.
index
- the index of the component to set.value
- the new value of the selected component.java.lang.IndexOutOfBoundsException
- if index
∉ [0, 1].default void set(double x, double y)
x
and y
.x
- the new value for the x-component of this tuple.y
- the new value for the y-component of this tuple.default void set(Tuple2DReadOnly other)
other
.other
- the other tuple to copy the values from. Not modified.default void set(Tuple3DReadOnly tuple3DReadOnly)
tuple3DReadOnly
tuple3DReadOnly
- the tuple 3D to copy the x and y components from. Not modified.default void set(double[] tupleArray)
x
, y
in order from the given array
tupleArray
.tupleArray
- the array containing the new values for this tuple's components. Not
modified.default void set(int startIndex, double[] tupleArray)
x
, y
in order from the given array
tupleArray
.startIndex
- the first index to start reading from in the array.tupleArray
- the array containing the new values for this tuple's components. Not
modified.default void set(float[] tupleArray)
x
, y
in order from the given array
tupleArray
.tupleArray
- the array containing the new values for this tuple's components. Not
modified.default void set(int startIndex, float[] tupleArray)
x
, y
in order from the given array
tupleArray
.startIndex
- the first index to start reading from in the array.tupleArray
- the array containing the new values for this tuple's components. Not
modified.default void set(org.ejml.data.DenseMatrix64F matrix)
x
, y
in order from the given column vector
starting to read from its first row index.matrix
- the column vector containing the new values for this tuple's components. Not
modified.default void set(int startRow, org.ejml.data.DenseMatrix64F matrix)
x
, y
in order from the given column vector
starting to read from startRow
.startRow
- the first row index to start reading in the dense-matrix.matrix
- the column vector containing the new values for this tuple's components. Not
modified.default void set(int startRow, int column, org.ejml.data.DenseMatrix64F matrix)
x
, y
in order from the given matrix starting to
read from startRow
at the column index column
.startRow
- the first row index to start reading in the dense-matrix.column
- the column index to read in the dense-matrix.matrix
- the column vector containing the new values for this tuple's components. Not
modified.default void setAndAbsolute(Tuple2DReadOnly other)
other
and then calls absolute()
.other
- the other tuple to copy the values from. Not modified.default void setAndNegate(Tuple2DReadOnly other)
other
and then calls negate()
.other
- the other tuple to copy the values from. Not modified.default void setAndScale(double scalar, Tuple2DReadOnly other)
other
and then scales it scale(double)
.scalar
- the scale factor to use on this tuple.other
- the other tuple to copy the values from. Not modified.default void setAndClipToMax(double max, Tuple2DReadOnly other)
other
and then calls clipToMax(double)
.max
- the maximum value for each component of this tuple.other
- the other tuple to copy the values from. Not modified.default void setAndClipToMin(double min, Tuple2DReadOnly other)
other
and then calls clipToMin(double)
.min
- the minimum value for each component of this tuple.other
- the other tuple to copy the values from. Not modified.default void setAndClipToMinMax(double min, double max, Tuple2DReadOnly other)
other
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.other
- the other tuple to copy the values from. Not modified.default void addX(double x)
x
to this tuple's x-component.x
- the value to add.default void addY(double y)
y
to this tuple's y-component.y
- the value to add.default void add(double x, double y)
x
, y
)-tuple to this tuple.
this = this + (x, y)
x
- the value to add to the x-component of this tuple.y
- the value to add to the y-component of this tuple.default void add(Tuple2DReadOnly other)
this = this + other
other
- the other tuple to add to this tuple.default void add(Tuple2DReadOnly tuple1, Tuple2DReadOnly 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 tuple's x-component.x
- the value to add.default void subY(double y)
y
to this tuple's y-component.y
- the value to add.default void sub(double x, double y)
x
, y
)-tuple to this tuple.
this = this - (x, y)
x
- the value to add to the x-component of this tuple.y
- the value to add to the y-component of this tuple.default void sub(Tuple2DReadOnly tupleReadOnly)
this = this - other
tupleReadOnly
- the other tuple to add to this tuple.default void sub(Tuple2DReadOnly tuple1, Tuple2DReadOnly tuple2)
this = tuple1 - tuple2
tuple1
- the first tuple. Not modified.tuple2
- the second 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)
/ this.x \ = / scalarX * this.x \ \ this.y / \ scalarY * this.y /
scalarX
- the scalar factor to use on the x-component of this tuple.scalarY
- the scalar factor to use on the y-component of this tuple.default void scaleAdd(double scalar, Tuple2DReadOnly other)
other
.
this = scalar * this + other
scalar
- the scale factor to use.other
- the tuple to add to this. Not modified.default void scaleAdd(double scalar, Tuple2DReadOnly tuple1, Tuple2DReadOnly 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, Tuple2DReadOnly other)
other
.
this = scalar * this - other
scalar
- the scale factor to use.other
- the tuple to subtract to this. Not modified.default void scaleSub(double scalar, Tuple2DReadOnly tuple1, Tuple2DReadOnly 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(Tuple2DReadOnly other, double alpha)
other
given the percentage
alpha
.
this = (1.0 - alpha) * this + alpha * other
other
- the other tuple used for the interpolation. Not modified.alpha
- the percentage used for the interpolation. A value of 0 will result in not
modifying this tuple, while a value of 1 is equivalent to setting this tuple to
other
.default void interpolate(Tuple2DReadOnly tuple1, Tuple2DReadOnly 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 tuple to tuple1
, while a value of 1 is equivalent to setting this tuple
to tuple2
.default void applyTransform(Transform transform)
transform
.
Note: transforming a point differs from transforming a vector in the way that the point can be translated, whereas the vector can be only rotated and scaled.
applyTransform
in interface Transformable
transform
- the geometric transform to apply on this tuple. Not modified.NotAMatrix2DException
- if the rotation part of transform
is not a
transformation in the XY plane.void applyTransform(Transform transform, boolean checkIfTransformInXYPlane)
transform
.
Note: transforming a point differs from transforming a vector in the way that the point can be translated, whereas the vector can be only rotated and scaled.
transform
- the geometric transform to apply on this tuple. Not modified.checkIfTransformInXYPlane
- whether this method should assert that the rotation part of
the given transform represents a transformation in the XY plane.NotAMatrix2DException
- if checkIfTransformInXYPlane == true
and the rotation
part of transform
is not a transformation in the XY plane.default void applyInverseTransform(Transform transform)
transform
.
Note: transforming a point differs from transforming a vector in the way that the point can be translated, whereas the vector can be only rotated and scaled.
sapplyInverseTransform
in interface Transformable
transform
- the geometric transform to apply on this vector. Not modified.NotAMatrix2DException
- if the rotation part of transform
is not a
transformation in the XY plane.void applyInverseTransform(Transform transform, boolean checkIfTransformInXYPlane)
transform
.
Note: transforming a point differs from transforming a vector in the way that the point can be translated, whereas the vector can be only rotated and scaled.
transform
- the geometric transform to apply on this tuple. Not modified.checkIfTransformInXYPlane
- whether this method should assert that the rotation part of
the given transform represents a transformation in the XY plane.NotAMatrix2DException
- if checkIfTransformInXYPlane == true
and the rotation
part of transform
is not a transformation in the XY plane.