Class Point3i

Object
Tuple3i
Point3i
All Implemented Interfaces:
Serializable, Comparable<ReadableTuple3i>, ReadableTuple3i

public final class Point3i extends Tuple3i
A three-dimensional point of int values.

We consider a point to be a tuple representing a single physical point in space.

Author:
Owen Feehan
See Also:
  • Field Details

    • ORIGIN

      public static final Point3i ORIGIN
      A constant Point3i where all dimensions are zero.
  • Constructor Details

    • Point3i

      public Point3i()
      Creates the points with a 0 in each dimension.
    • Point3i

      public Point3i(int valueForAllDimensions)
      Create with an identical value in each dimension.
      Parameters:
      valueForAllDimensions - the value for each dimension.
    • Point3i

      public Point3i(int x, int y, int z)
      Create with values for each dimension.
      Parameters:
      x - the value for the X-dimension.
      y - the value for the Y-dimension.
      z - the value for the Z-dimension.
    • Point3i

      public Point3i(ReadableTuple3i point)
      Creates with the same values as an existing ReadableTuple3i.
      Parameters:
      point - to copy values from.
  • Method Details

    • distance

      public double distance(Point3i point)
      The Euclidean distance between this point and another.
      Parameters:
      point - the other point to a measure a distance to.
      Returns:
      the distance.
    • distanceSquared

      public int distanceSquared(Point3i point)
      The square of the Euclidean distance between this point and another Point3i.
      Parameters:
      point - the other point to a measure a distance to.
      Returns:
      the distance squared.
    • distanceSquared

      public double distanceSquared(Point3d point)
      The square of the Euclidean distance between this point and another Point3d.
      Parameters:
      point - the other point to a measure a distance to.
      Returns:
      the distance squared.
    • distanceMax

      public int distanceMax(Point3i point)
      The maximum distance across any individual axis to another point.
      Parameters:
      point - the point to consider distances to, across each axis.
      Returns:
      the maximal distance along any one particular axis.
    • duplicateChangeZ

      public Point3i duplicateChangeZ(int zValueToAssign)
      Description copied from interface: ReadableTuple3i
      Creates a copy of the current tuple, but with a different Z-component value.
      Parameters:
      zValueToAssign - the value to assign in the Z-axis.
      Returns:
      a copy of the current object with changed Z-component value.
    • immutableAdd

      public static Point3i immutableAdd(ReadableTuple3i tuple1, ReadableTuple3i tuple2)
      Adds two tuples immutably.
      Parameters:
      tuple1 - the first tuple to add.
      tuple2 - the second tuple to add.
      Returns:
      a newly created point, where each dimension is the sum of the corresponding dimensions in the points.
    • immutableAdd

      public static Point3i immutableAdd(ReadableTuple3i tuple1, ReadableTuple3i tuple2, ReadableTuple3i tuple3)
      Adds three tuples immutably.
      Parameters:
      tuple1 - the first tuple to add.
      tuple2 - the second tuple to add.
      tuple3 - the third tuple to add.
      Returns:
      a newly created point, where each dimension is the sum of the corresponding dimensions in the points.
    • immutableAdd

      public static Point3i immutableAdd(ReadableTuple3i tuple, int x, int y, int z)
      Adds values to a tuple immutably.
      Parameters:
      tuple - the tuple to add.
      x - the value to add to the X-component.
      y - the value to add to the Y-component.
      z - the value to add to the Z-component.
      Returns:
      a newly created point, where each dimension is the sum of the corresponding dimensions in the points.
    • immutableSubtract

      public static Point3i immutableSubtract(ReadableTuple3i tuple, ReadableTuple3i toSubtract)
      Subtracts two tuples immutably.
      Parameters:
      tuple - the tuple to subtract from.
      toSubtract - the tuple to subtract.
      Returns:
      a newly created point, where each dimension is the subtraction of the corresponding dimensions in the points.
    • immutableScale

      public static Point3i immutableScale(ReadableTuple3i point, int factor)
      Multiplies each component by factor without changing any values in an existing point.

      This is an immutable operation that produces a new point.

      Parameters:
      point - the point whose component's will be scaled.
      factor - the factor to scale by.
      Returns:
      a newly created point with scaled values.
    • elementwiseOperation

      public static Point3i elementwiseOperation(ReadableTuple3i tuple1, ReadableTuple3i tuple2, IntBinaryOperator operator)
      Creates a new point by applying a pairwise operation to each dimension's values for two tuples.
      Parameters:
      tuple1 - the first tuple.
      tuple2 - the second tuple.
      operator - the operator to apply to each dimension of the tuples to produce the corresponding dimension in the returned tuple.
      Returns:
      a newly-created point arising from applying operator to the components of each tuple.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Tuple3i
    • canEqual

      protected boolean canEqual(Object other)
      Overrides:
      canEqual in class Tuple3i
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Tuple3i