Package primitives

Class Triple

java.lang.Object
primitives.Triple
Direct Known Subclasses:
Point, Vector

public abstract class Triple
extends java.lang.Object
A class that has three values, (x, y, z)
  • Field Summary

    Fields
    Modifier and Type Field Description
    double x
    The x coordinate.
    double y
    The y coordinate.
    double z
    The z coordinate.
  • 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 this Triple's values are equal to the given values.
    boolean equals​(java.lang.Object o)  
    int hashCode()  
    java.lang.String toString()
    Returns the Triple as a string in the cartesian representation, e.g.
    <T extends Triple>
    T
    transform​(java.util.function.DoubleBinaryOperator transformation, Triple aux, DoubleTriFunction<T> creator)
    Creates a new Triple of the subtype returned by creator which is a transformation of this Triple by applying the given transformation to each of the coordinates.
    <T extends Triple>
    T
    transform​(java.util.function.DoubleUnaryOperator transformation, DoubleTriFunction<T> creator)
    Similar to transform(DoubleBinaryOperator, Triple, DoubleTriFunction) but does not require an auxiliary Triple, 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 x
      The x coordinate.
    • y

      public final double y
      The y coordinate.
    • z

      public final double z
      The 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 new Triple of the subtype returned by creator which is a transformation of this Triple 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 auxiliary Triple 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 new Triple
      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 to transform(DoubleBinaryOperator, Triple, DoubleTriFunction) but does not require an auxiliary Triple, 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 new Triple
      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 this Triple'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 class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public java.lang.String toString()
      Returns the Triple as a string in the cartesian representation, e.g. "(0, 0, 0)"
      Overrides:
      toString in class java.lang.Object