Class Point2D

java.lang.Object
eu.svjatoslav.sixth.e3d.geometry.Point2D
All Implemented Interfaces:
Cloneable

public class Point2D extends Object implements Cloneable
Used to represent point in a 2D space or vector.
See Also:
  • Field Details

    • x

      public double x
    • y

      public double y
  • Constructor Details

    • Point2D

      public Point2D()
    • Point2D

      public Point2D(double x, double y)
    • Point2D

      public Point2D(Point2D parent)
  • Method Details

    • add

      public Point2D add(Point2D otherPoint)
      Add other point to current point. Value of other point will not be changed.
      Returns:
      current point.
    • isZero

      public boolean isZero()
      Returns:
      true if current point coordinates are equal to zero.
    • clone

      public Point2D clone()
      Overrides:
      clone in class Object
    • clone

      public void clone(Point2D otherPoint)
      Copy coordinates from other point to current point. Value of other point will not be changed.
    • setToMiddle

      public Point2D setToMiddle(Point2D p1, Point2D p2)
      Set current point to middle of two other points.
      Parameters:
      p1 - first point.
      p2 - second point.
      Returns:
      current point.
    • getAngleXY

      public double getAngleXY(Point2D anotherPoint)
    • getDistanceTo

      public double getDistanceTo(Point2D anotherPoint)
      Compute distance to another point.
      Parameters:
      anotherPoint - point to compute distance to.
      Returns:
      distance from current point to another point.
    • getVectorLength

      public double getVectorLength()
      Calculate length of vector.
      Returns:
      length of vector.
    • invert

      public Point2D invert()
      Invert current point.
      Returns:
      current point.
    • roundToInteger

      public void roundToInteger()
      Round current point coordinates to integer.
    • subtract

      public Point2D subtract(Point2D otherPoint)
      Subtract other point from current point. Value of other point will not be changed.
      Returns:
      current point.
    • to3D

      public Point3D to3D()
      Convert current point to 3D point. Value of the z coordinate will be set to zero.
      Returns:
      3D point.
    • zero

      public Point2D zero()
      Set current point to zero.
      Returns:
      current point.
    • toString

      public String toString()
      Overrides:
      toString in class Object