Package il.ac.idc.jdt

Class Point

java.lang.Object
il.ac.idc.jdt.Point
All Implemented Interfaces:
Serializable, Comparable<Point>

public class Point extends Object implements Comparable<Point>, Serializable
This class represents a 3D point, with some simple geometric methods (pointLineTest).
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default Constructor.
    Point(double x, double y)
    constructs a 3D point with a z value of 0.
    Point(double x, double y, double z)
    constructs a 3D point
    simple copy constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    double
     
    double
     
    boolean
    return true iff this point [x,y] coordinates are the same as p [x,y] coordinates.
    double
    returns the x-coordinate of this point.
    double
    returns the y-coordinate of this point.
    double
    returns the z-coordinate of this point.
    int
     
    int
    tests the relation between this point (as a 2D [x,y] point) and a 2D segment a,b (the Z values are ignored), returns one of the following: LEFT, RIGHT, INFRONTOFA, BEHINDB, ONSEGMENT
    void
    setX(double x)
    Sets the x coordinate.
    void
    setY(double y)
    Sets the y coordinate.
    void
    setZ(double z)
    Sets the z coordinate.
     

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • Point

      public Point()
      Default Constructor.
      constructs a 3D point at (0,0,0).
    • Point

      public Point(double x, double y, double z)
      constructs a 3D point
    • Point

      public Point(double x, double y)
      constructs a 3D point with a z value of 0.
    • Point

      public Point(Point p)
      simple copy constructor
  • Method Details

    • getX

      public double getX()
      returns the x-coordinate of this point.
    • setX

      public void setX(double x)
      Sets the x coordinate.
      Parameters:
      x - The new x coordinate.
    • getY

      public double getY()
      returns the y-coordinate of this point.
    • setY

      public void setY(double y)
      Sets the y coordinate.
      Parameters:
      y - The new y coordinate.
    • getZ

      public double getZ()
      returns the z-coordinate of this point.
    • setZ

      public void setZ(double z)
      Sets the z coordinate.
      Parameters:
      z - The new z coordinate.
    • toString

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

      public double distance(Point p)
      Returns:
      the L2 distanse NOTE: 2D only!!!
    • distance3D

      public double distance3D(Point p)
      Returns:
      the L2 distanse NOTE: 3D only!!!
    • pointLineTest

      public int pointLineTest(Point a, Point b)
      tests the relation between this point (as a 2D [x,y] point) and a 2D segment a,b (the Z values are ignored), returns one of the following: LEFT, RIGHT, INFRONTOFA, BEHINDB, ONSEGMENT
      Parameters:
      a - the first point of the segment.
      b - the second point of the segment.
      Returns:
      the value (flag) of the relation between this point and the a,b line-segment.
    • hashCode

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

      public boolean equals(Object obj)
      return true iff this point [x,y] coordinates are the same as p [x,y] coordinates. (the z value is ignored).
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(Point o)
      Specified by:
      compareTo in interface Comparable<Point>