Class Point2

java.lang.Object
qupath.lib.geom.Point2
All Implemented Interfaces:
Externalizable, Serializable, Point

public class Point2 extends Object implements Externalizable
A 2D point (x & y coordinates).
Author:
Pete Bankhead
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for a point at location (0,0).
    Point2(double x, double y)
    Point constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    dim()
    Number of values used to represent this point.
    double
    distance(double x, double y)
    Calculate the distance between this point and a specified x and y location.
    double
    Calculate the distance to another point, with the same Point.dim().
    double
    Calculate the distance between this point and another point.
    double
    distanceSq(double x, double y)
    Calculate the squared distance between this point and a specified x and y location.
    double
    Calculate the squared distance to another point, with the same Point.dim().
    boolean
     
    double
    get(int dim)
    Get the value of the ordinate for the specified dimension.
    double
    Get the x coordinate of this point.
    double
    Get the y coordinate of this point.
    int
     
    void
     
     
    void
     

    Methods inherited from class java.lang.Object

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

    • Point2

      public Point2()
      Default constructor for a point at location (0,0).
    • Point2

      public Point2(double x, double y)
      Point constructor.
      Parameters:
      x -
      y -
  • Method Details

    • hashCode

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

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

      public double getX()
      Get the x coordinate of this point.
      Returns:
    • getY

      public double getY()
      Get the y coordinate of this point.
      Returns:
    • distanceSq

      public double distanceSq(double x, double y)
      Calculate the squared distance between this point and a specified x and y location.
      Parameters:
      x -
      y -
      Returns:
    • distance

      public double distance(double x, double y)
      Calculate the distance between this point and a specified x and y location.
      Parameters:
      x -
      y -
      Returns:
    • distance

      public double distance(Point2 p)
      Calculate the distance between this point and another point.
      Parameters:
      p -
      Returns:
    • get

      public double get(int dim)
      Description copied from interface: Point
      Get the value of the ordinate for the specified dimension.
      Specified by:
      get in interface Point
      Parameters:
      dim -
      Returns:
    • dim

      public int dim()
      Description copied from interface: Point
      Number of values used to represent this point.

      For an x,y coordinate pair this should return 2.

      Specified by:
      dim in interface Point
      Returns:
    • toString

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

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException
    • distanceSq

      public double distanceSq(Point p)
      Description copied from interface: Point
      Calculate the squared distance to another point, with the same Point.dim().
      Specified by:
      distanceSq in interface Point
      Parameters:
      p -
      Returns:
      See Also:
    • distance

      public double distance(Point p)
      Description copied from interface: Point
      Calculate the distance to another point, with the same Point.dim().
      Specified by:
      distance in interface Point
      Parameters:
      p -
      Returns:
      See Also: