Class Point2D


  • public final class Point2D
    extends Object
    Class representing a 2d coordinate.
    Author:
    Gregory Van den Borre
    • Field Detail

      • ZERO

        public static final Point2D ZERO
        0,0 coordinate point.
      • x

        public final float x
        X coordinate.
      • y

        public final float y
        Y coordinate.
    • Method Detail

      • valueOf

        public static Point2D valueOf​(float x,
                                      float y)
      • add

        public Point2D add​(float xValue,
                           float yValue)
        Add this point values by the parameter x,y values.
        Parameters:
        xValue - Values to add to this point X value.
        yValue - Values to add to this point Y value.
        Returns:
        The newly created point.
      • add

        public Point2D add​(Point2D point)
        Add this point values by the parameter point values.
        Parameters:
        point - Values to use.
        Returns:
        The newly created point.
      • equals

        public boolean equals​(Object obj)
        Overrides:
        equals in class Object
        Parameters:
        obj - Other object to test for equality.
        Returns:
        true only if the other object is a not null Point2D with the same coordinates.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
        Returns:
        A hash code computed from the x and y values.
      • multiplyByScalar

        public Point2D multiplyByScalar​(float scalar)
        Multiply the point x and y by the scalar value.
        Parameters:
        scalar - Value to multiply.
        Returns:
        The newly created point.
      • subtract

        public Point2D subtract​(float xValue,
                                float yValue)
        Subtract this point values by the parameter x,y values.
        Parameters:
        xValue - Values to remove from this point X value.
        yValue - Values to remove from this point Y value.
        Returns:
        The newly created point.
      • subtract

        public Point2D subtract​(Point2D point)
        Subtract this point values by the parameter point values.
        Parameters:
        point - Values to use.
        Returns:
        The newly created point.
      • toString

        public String toString()
        Overrides:
        toString in class Object
        Returns:
        X and Y values.