Package primitives
Class Triple
java.lang.Object
primitives.Triple
public abstract class Triple
extends java.lang.Object
A class that has three values, (x, y, z)
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
Triple(double x, double y, double z)
Construct a triple with the given coordinates. -
Method Summary
Modifier and Type Method Description boolean
equals(double x, double y, double z)
Checks if thisTriple
's values are equal to the given values.boolean
equals(java.lang.Object o)
int
hashCode()
java.lang.String
toString()
Returns theTriple
as a string in the cartesian representation, e.g.<T extends Triple>
Ttransform(java.util.function.DoubleBinaryOperator transformation, Triple aux, DoubleTriFunction<T> creator)
<T extends Triple>
Ttransform(java.util.function.DoubleUnaryOperator transformation, DoubleTriFunction<T> creator)
Similar totransform(DoubleBinaryOperator, Triple, DoubleTriFunction)
but does not require an auxiliaryTriple
, since the transformation when called in this way does not depend on a second coordinate.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
x
public final double xThe x coordinate. -
y
public final double yThe y coordinate. -
z
public final double zThe z coordinate.
-
-
Constructor Details
-
Triple
protected Triple(double x, double y, double z)Construct a triple with the given coordinates.- Parameters:
x
- The x coordinate.y
- The y coordinate.z
- The z coordinate.
-
-
Method Details
-
transform
public <T extends Triple> T transform(java.util.function.DoubleBinaryOperator transformation, Triple aux, DoubleTriFunction<T> creator)Creates a newTriple
of the subtype returned bycreator
which is a transformation of thisTriple
by applying the given transformation to each of the coordinates.- Type Parameters:
T
- The type of Triple to return.- Parameters:
transformation
- A function which receives two doubles and returns another double.aux
- An auxiliaryTriple
whose corresponding coordinate may (or may not) be used in the transformation function in order to calculate each of the new coordinates.creator
- A function which receives three doubles and returns a newTriple
- Returns:
- The
Triple
made up of applying the transformation to each of the three coordinates.
-
transform
public <T extends Triple> T transform(java.util.function.DoubleUnaryOperator transformation, DoubleTriFunction<T> creator)Similar totransform(DoubleBinaryOperator, Triple, DoubleTriFunction)
but does not require an auxiliaryTriple
, since the transformation when called in this way does not depend on a second coordinate.- Type Parameters:
T
- The type of Triple to return.- Parameters:
transformation
- A function which receives a dingle double and returns another double.creator
- A function which receives three doubles and returns a newTriple
- Returns:
- The
Triple
made up of applying the transformation to each of the three coordinates.
-
equals
public boolean equals(double x, double y, double z)Checks if thisTriple
's values are equal to the given values.- Parameters:
x
- The x value to compare.y
- The y value to compare.z
- The z value to compare.- Returns:
- True if this
Triple
's values are equal to the given values.
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()Returns theTriple
as a string in the cartesian representation, e.g. "(0, 0, 0)"- Overrides:
toString
in classjava.lang.Object
-