Package primitives

Class Point

java.lang.Object
primitives.Triple
primitives.Point

public class Point
extends Triple
The Point class represents a Point in three dimensional space.
  • Field Details

    • ORIGIN

      public static final Point ORIGIN
      The point (0, 0, 0).
    • NEGATIVE_INFINITY

      public static final Point NEGATIVE_INFINITY
      The point (-INF, -INF, -INF).
    • POSITIVE_INFINITY

      public static final Point POSITIVE_INFINITY
      The point (INF, INF, INF).
  • Constructor Details

    • Point

      public Point​(double x, double y, double z)
      Constructs a Point from three coordinates.
      Parameters:
      x - The x-coordinate.
      y - The y-coordinate.
      z - The z-coordinate.
  • Method Details

    • add

      public Point add​(Vector vector)
      Adds a NonZeroVector to this Point and returns the resulting Point.
      Parameters:
      vector - The Vector to add to this Point.
      Returns:
      The Point resulting from adding the NonZeroVector to this Point.
    • subtract

      public Point subtract​(Vector vector)
      Subtract a Vector from this Point and returns the resulting Point.
      Parameters:
      vector - The Vector to subtract from this Point.
      Returns:
      The Point resulting from dubtracting the Vector from this Point.
    • vectorTo

      public Vector vectorTo​(Point target)
      Constructs a Vector from this Point to the given Point. With this method, the zero vector may be returned.
      Parameters:
      target - The coordinate where the Vector is to end, if it were to start from this Point.
      Returns:
      The Vector from this Point to the given Point.
    • nonZeroVectorTo

      public NonZeroVector nonZeroVectorTo​(Point target)
      Constructs a NonZeroVector from this Point to the given Point.
      Parameters:
      target - The coordinate where the NonZeroVector is to end, if it were to start from this Point.
      Returns:
      The NonZeroVector from this Point to the given Point.
      Throws:
      ZeroVectorException - if the target is equal to this Point.
    • distance

      public double distance​(Point target)
      Calculates the distance between this Point and the target Point.
      Parameters:
      target - The Point to calculate the distance to.
      Returns:
      The distance between this Point and the target Point.
    • squareDistance

      public double squareDistance​(Point target)
      The square of the distance between this Point and the target Point. This number is much more efficient to compute than distance(primitives.Point) since it does not involve a square root.
      Parameters:
      target - The Point to calculate the distance to.
      Returns:
      The square of the distance between this Point and the target Point.
    • isFinite

      public boolean isFinite()
      Determine if a point has finite values in each of its coordinates.
      Returns:
      true if all coordinates are finite, or false if at least one coordinate is infinite.
    • toString

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