Class Point2D


  • public class Point2D
    extends java.lang.Object
    Two-dimensional point, which also has functions as a two-dimensional vectors
    • Field Summary

      Fields 
      Modifier and Type Field Description
      double x  
      double y  
    • Constructor Summary

      Constructors 
      Constructor Description
      Point2D()  
      Point2D​(double x, double y)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double angle​(Point2D vector2d)
      Computes the angle between the given vector and the position vector of the current point
      double distance​(double px, double py)
      Computes the euclidean distance bewteen (px,py) to the current point
      static double distance​(double x1, double y1, double x2, double y2)
      Computes the euclidean distance between (x1,y1) and (x2,y2)
      double distance​(Point2D point)  
      double dot​(Point2D vector2d)
      Computes the dot-product of the given vector with position vector of the current point
      double getX()  
      double getY()  
      double length()  
      double lengthSquared()  
      void normalize()  
      void normalize​(Point2D vector2d)
      Scales the coordinates with 1/(length of given vector)
      void scale​(double d)  
      void setLocation​(double x, double y)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • x

        public double x
      • y

        public double y
    • Constructor Detail

      • Point2D

        public Point2D()
      • Point2D

        public Point2D​(double x,
                       double y)
    • Method Detail

      • distance

        public static double distance​(double x1,
                                      double y1,
                                      double x2,
                                      double y2)
        Computes the euclidean distance between (x1,y1) and (x2,y2)
        Parameters:
        x1 -
        y1 -
        x2 -
        y2 -
        Returns:
        euclidean distance between (x1,y1) and (x2,y2)
      • distance

        public double distance​(double px,
                               double py)
        Computes the euclidean distance bewteen (px,py) to the current point
        Parameters:
        px -
        py -
        Returns:
      • distance

        public double distance​(Point2D point)
      • getX

        public double getX()
      • getY

        public double getY()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • scale

        public final void scale​(double d)
      • dot

        public final double dot​(Point2D vector2d)
        Computes the dot-product of the given vector with position vector of the current point
        Parameters:
        vector2d -
        Returns:
      • length

        public final double length()
      • lengthSquared

        public final double lengthSquared()
      • normalize

        public final void normalize​(Point2D vector2d)
        Scales the coordinates with 1/(length of given vector)
        Parameters:
        vector2d -
      • normalize

        public final void normalize()
      • angle

        public final double angle​(Point2D vector2d)
        Computes the angle between the given vector and the position vector of the current point
        Parameters:
        vector2d -
        Returns:
      • setLocation

        public void setLocation​(double x,
                                double y)