Class Point3d

Object
Tuple3d
Point3d
All Implemented Interfaces:
Serializable

public final class Point3d extends Tuple3d
A three-dimensional point of double values.

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

Author:
Owen Feehan
See Also:
  • Constructor Details

    • Point3d

      public Point3d(Point3f point)
      Creates with the same values as an existing Point3d.
      Parameters:
      point - to copy values from.
    • Point3d

      public Point3d(Tuple3d point)
      Creates with the same values as an existing Tuple3d.
      Parameters:
      point - to copy values from.
    • Point3d

      public Point3d(double x, double y, double 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.
    • Point3d

      public Point3d()
  • Method Details

    • distance

      public double distance(Point3d point)
      The Euclidean distance between this point and another Point3d.
      Parameters:
      point - the other point to a measure a distance to.
      Returns:
      the distance.
    • 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.
    • distanceSquared

      public double 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.
    • dropZ

      public Point3d dropZ()
      Creates a new point with identical x and y values, but with z set to 0.

      This is an immutable operation that does not affect current state.

      Returns:
      the new point.
    • min

      public Point3d min(Tuple3d point)
      Element-wise minimum between this point and another.
      Parameters:
      point - the other point.
      Returns:
      a new point containing the minimum of the x, y, z components.
    • min

      public Point3d min(ReadableTuple3i point)
      Element-wise minimum between this point and another.
      Parameters:
      point - the other point.
      Returns:
      a new point containing the minimum of the x, y, z components.
    • max

      public Point3d max(double val)
      Element-wise maximum between this point and a scalar.
      Parameters:
      val - the scalar.
      Returns:
      a new point containing the minimum of the x, y, z components.
    • equalsTolerance

      public boolean equalsTolerance(Point3d other, double delta)
      Checks if this point is equal to another Point3d accepting a tolerance between double values.
      Parameters:
      other - the other point to check for equality with.
      delta - the maximum difference before two double values are considered to be unequal.
      Returns:
      true iff all dimensions of the point are equal (within the tolerance).
    • toArray

      public double[] toArray()
      Converts the point to an array.
      Returns:
      a newly created array with three elements, respectively for x, y and z components.
    • toArrayXY

      public double[] toArrayXY()
      Converts the X and Y dimensions of the point to an array.
      Returns:
      a newly created array with two elements, respectively for x and y components.
    • max

      public Point3d max(Tuple3d point)
      Element-wise maximum between this point and another.
      Parameters:
      point - the other point.
      Returns:
      a new point containing the minimum of the x, y, z components.
    • immutableAdd

      public static Point3d immutableAdd(Tuple3d tuple1, Tuple3d 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 Point3d immutableAdd(Point3d point, int x, int y, int z)
      Adds values to a point immutably.
      Parameters:
      point - the point 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 Point3d immutableSubtract(Tuple3d tuple, Tuple3d toSubtract)
      Subtracts a Tuple3d from a Tuple3d 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.
    • immutableSubtract

      public static Point3d immutableSubtract(Tuple3i tuple, Tuple3d toSubtract)
      Subtracts a Tuple3d from a Tuple3i 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 Point3d immutableScale(Tuple3d tuple, int factor)
      Scales a tuple immutably.
      Parameters:
      tuple - the tuple to scale.
      factor - what to multiply each dimension by.
      Returns:
      a newly created point, where each component is scaled by factor.
    • equals

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

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

      public int hashCode()
      Overrides:
      hashCode in class Tuple3d