java.lang.Object
com.marginallyclever.donatello.Point2D

public class Point2D
extends java.lang.Object
Represents a cartesian coordinate in 2D, with double precision.
  • Field Summary

    Fields
    Modifier and Type Field Description
    double x
    the cartesian coordinates.
    double y
    the cartesian coordinates.
  • Constructor Summary

    Constructors
    Constructor Description
    Point2D()
    Constructor for subclasses to call.
    Point2D​(double x0, double y0)
    Sets this to some cartesian (x0,y0) value.
    Point2D​(Point2D b)
    Constructor sets this to some Point2D
  • Method Summary

    Modifier and Type Method Description
    double distance​(Point2D p)
    Returns the distance to some other Point2D.
    double distanceSquared​(Point2D p)
    Returns the square of the distance to some other Point2D.
    double length()
    Returns the distance to the origin.
    double lengthSquared()
    Returns the square of the distance to the origin.
    void scale​(double scale)
    Scales this point about the origin.
    void set​(double x0, double y0)
    Sets this to some cartesian (x0,y0) value.
    void set​(Point2D p)
    Sets this to some other Point2D.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • x

      public double x
      the cartesian coordinates.
    • y

      public double y
      the cartesian coordinates.
  • Constructor Details

    • Point2D

      public Point2D()
      Constructor for subclasses to call.
    • Point2D

      public Point2D​(Point2D b)
      Constructor sets this to some Point2D
      Parameters:
      b - the Point2D to copy.
    • Point2D

      public Point2D​(double x0, double y0)
      Sets this to some cartesian (x0,y0) value.
      Parameters:
      x0 - the new x value.
      y0 - the new y value.
  • Method Details

    • set

      public void set​(double x0, double y0)
      Sets this to some cartesian (x0,y0) value.
      Parameters:
      x0 - the new x value.
      y0 - the new y value.
    • set

      public void set​(Point2D p)
      Sets this to some other Point2D.
      Parameters:
      p - the other Point2D.
    • lengthSquared

      public double lengthSquared()
      Returns the square of the distance to the origin.
      Returns:
      the square of the distance to the origin.
    • length

      public double length()
      Returns the distance to the origin.
      Returns:
      the distance to the origin.
    • scale

      public void scale​(double scale)
      Scales this point about the origin.
      Parameters:
      scale - the amount to scale
    • distanceSquared

      public double distanceSquared​(Point2D p)
      Returns the square of the distance to some other Point2D.
      Parameters:
      p - the other Point2D.
      Returns:
      the square of the distance to some other Point2D.
    • distance

      public double distance​(Point2D p)
      Returns the distance to some other Point2D.
      Parameters:
      p - the other Point2D.
      Returns:
      the distance to some other Point2D.