java.lang.Object
com.amalgamasimulation.geometry.geometry3d.Point3D

public class Point3D extends Object
Class representing a point in 3D space. The point has x, y and z coordinates of type double. This point can be used as a basic structural element for 3D geometry operations and is backed by Point for its x and y coordinates.

NaNs and infinite coordinates are allowed and there are no checks that prevent from creating points with such coordinates. These coordinates are not supported in most methods which can cause errors; such special cases are not described below.

Author:
Andrey Malykhanov
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new 3D point with (0, 0, 0) coordinates.
    Point3D(double x, double y, double z)
    Creates a new point with the specified coordinates.
    Point3D(Point point, double z)
    Creates a new point with x and y taken from the specified 2D point and the specified z-coordinate.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the distance from this point to the specified point.
    boolean
     
     
    Returns the 2D projection (x and y coordinates) of this point.
    double
    Returns the x-coordinate (abscissa) of the point.
    double
    Returns the y-coordinate (ordinate) of the point.
    double
    Returns the z-coordinate of the point.
    int
     
     
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Point3D

      public Point3D()
      Creates a new 3D point with (0, 0, 0) coordinates.
    • Point3D

      public Point3D(Point point, double z)
      Creates a new point with x and y taken from the specified 2D point and the specified z-coordinate.
      Parameters:
      point - 2D Point providing x and y coordinates
      z - z-coordinate of the point
    • Point3D

      public Point3D(double x, double y, double z)
      Creates a new point with the specified coordinates.
      Parameters:
      x - x-coordinate of the point
      y - y-coordinate of the point
      z - z-coordinate of the point
  • Method Details

    • getPoint2D

      public Point getPoint2D()
      Returns the 2D projection (x and y coordinates) of this point.
      Returns:
      2D projection of this point
    • getX

      public double getX()
      Returns the x-coordinate (abscissa) of the point.
      Returns:
      x-coordinate of the point
    • getY

      public double getY()
      Returns the y-coordinate (ordinate) of the point.
      Returns:
      y-coordinate of the point
    • getZ

      public double getZ()
      Returns the z-coordinate of the point.
      Returns:
      z-coordinate of the point
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • distanceTo

      public double distanceTo(Point3D other)
      Returns the distance from this point to the specified point. The returned value cannot be negative.
      Parameters:
      other - the specified point
      Returns:
      distance from this point to the specified point
    • getCopy

      public Point3D getCopy()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toCodeString

      public String toCodeString()