Class CartesianPoint

java.lang.Object
com.j3d.engine.math.BasePoint<Double>
com.j3d.engine.math.CartesianPoint

public class CartesianPoint extends BasePoint<Double>
CartesianPoint, not to be confused with ScreenPoint, represents a point in 2D space. (On the Cartesian AxisPlane, where (0, 0) is the centre of the window.)

All 2d points should be calculated in CartesianPoint, but when you want to show it on the screen, converted to a ScreenPoint

Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • EPSILON

      private static final double EPSILON
      used for comparing double values without running into floating point errors.
      See Also:
  • Constructor Details

    • CartesianPoint

      public CartesianPoint()
      Default Constructor. Constructs a null CartesianPoint. This is probably a bad idea.
    • CartesianPoint

      public CartesianPoint(double X, double Y)
      Constructor with X and Y
      Parameters:
      X - X-coordiante
      Y - Y-coordinate
  • Method Details

    • isNotEmpty

      public boolean isNotEmpty()
      If this Cartesian Point is empty
      Returns:
      boolean
    • toScreen

      public ScreenPoint toScreen()
      Converts the Cartesian Point to a ScreenPoint using the global properties defined by Conversion.global()
      Returns:
      A ScreenPoint
    • toScreen

      public ScreenPoint toScreen(Conversion conversion)
      Converts the Cartesian Point to a ScreenPoint using provided properties
      Parameters:
      conversion - The conversion properties
      Returns:
      A ScreenPoint representing the converted coordinates.
    • toScreen

      public ScreenPoint toScreen(ConversionWithOffset conversion)
      Converts the Cartesian Point to a ScreenPoint using the provided properties.
      Parameters:
      conversion - The conversion properties
      Returns:
      A sScreenPoint representing the converted coordinates
    • fromList

      public static CartesianPoint fromList(ArrayList<? extends Number> arr)
      Converts a 2-dimensional array into a cartesian point.

      Generally used by Jaiva Implementation where points can be represented by [X, Y]

      Parameters:
      arr - The array.
      Returns:
      The new cartesian point
    • toArray

      public ArrayList<Double> toArray()
      Returns:
      A 2 Dimensional ArrayList of doubles.
    • toString

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

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

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

      public double distanceTo(CartesianPoint other)
      Calculates the distance between this point and another point.
      Parameters:
      other - The other point.
      Returns:
      The distance.
    • distanceSquaredTo

      public double distanceSquaredTo(CartesianPoint other)
      Calculates the distance between this point and another point without the square root.
      Parameters:
      other - The other point.
      Returns:
      The distance.
    • friendlyString

      public String friendlyString()