Class FloatPoint

    • Constructor Detail

      • FloatPoint

        public FloatPoint​(float x,
                          float y)
        Creates a point from given coordinates
        Parameters:
        x - coordinate
        y - coordinate
      • FloatPoint

        public FloatPoint​(Point2D point)
    • Method Detail

      • subtract

        public FloatPoint subtract​(float subX,
                                   float subY)
        Returns a point with this point's coordinates subtracted by the given coordinates.
        Parameters:
        subX - the length to be subtracted from x coordinate
        subY - the length to be subtracted from y coordinate
        Returns:
        new point.
      • subtract

        public FloatPoint subtract​(FloatPoint sub)
        Returns a point with this point's coordinates subtracted by the given point.
        Parameters:
        sub - a vector to be subtracted.
        Returns:
        a new point.
      • add

        public FloatPoint add​(int addX,
                              int addY)
        Returns a point with this point's coordinates added with the given coordinates.
        Parameters:
        addX - length to be added to x coordinate
        addY - length to be added to y coordinate
        Returns:
        new point.
      • add

        public FloatPoint add​(FloatPoint add)
        Returns a point with this point's coordinates added with the given point.
        Parameters:
        add - a vector to be added.
        Returns:
        new point.
      • multiply

        public FloatPoint multiply​(float mult)
        Returns a point which is a multiplication of this point
        Parameters:
        mult - the scale to multiply.
        Returns:
        new point.
      • getIntPoint

        public IntPoint getIntPoint()
        Returns an integer rounded version of this point
        Returns:
        integer representation of the point.
      • length

        public float length()
        Returns the length of this point's vector
        Returns:
        the distance to origin.
      • unitVector

        public FloatPoint unitVector()
        Returns the unit vector for this point's vector
        Returns:
        normalized direction of the vector.
      • rotate

        public FloatPoint rotate​(double radAngle)
        Returns this point's vector rotated according to the radian angle
        Parameters:
        radAngle - angle in radians
        Returns:
        rotated vector.
      • toString

        public String toString()
        Returns a string representation of this object
        Overrides:
        toString in class Point2D.Float
        Returns:
        string representing this point.