Class JavaPoint2D

  • All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    MetaJavaPoint2D

    public class JavaPoint2D
    extends AbstractJavaPoint<JavaPoint2D>

    Java Representation of a point. There is a Point in java.awt.Point available, but this is a int representation internal. There are some use-cases, where a double representation is needed.

    Since:
    1.0
    Author:
    Andreas Pointner
    See Also:
    Serialized Form
    • Constructor Detail

      • JavaPoint2D

        public JavaPoint2D​(double x,
                           double y)
        Parameters:
        x - x-coordinate
        y - y-coordinate
    • Method Detail

      • sub

        public JavaPoint2D sub​(JavaPoint2D vector)
        Subtracts the given JavaPoint from this.
        Specified by:
        sub in class AbstractJavaPoint<JavaPoint2D>
        Parameters:
        vector - The JavaPoint to be subtracted from this
        Returns:
        A new instance holding the result of the vector subtraction
      • add

        public JavaPoint2D add​(JavaPoint2D vector)
        Adds the given JavaPoint to this.
        Specified by:
        add in class AbstractJavaPoint<JavaPoint2D>
        Parameters:
        vector - The JavaPoint to be added to this
        Returns:
        A new instance holding the result of the vector addition
      • mult

        public JavaPoint2D mult​(double scalar)
        Multiplies this by the given scalar.
        Specified by:
        mult in class AbstractJavaPoint<JavaPoint2D>
        Parameters:
        scalar - The scalar to be multiplied by this
        Returns:
        A new instance holding the result of the multiplication
      • mult

        public JavaPoint2D mult​(JavaPoint2D vector)
        Multiplies this by the given vector.
        Specified by:
        mult in class AbstractJavaPoint<JavaPoint2D>
        Parameters:
        vector - The vector to be multiplied by this
        Returns:
        A new instance holding the result of the multiplication
      • div

        public JavaPoint2D div​(double scalar)
        Divides this by the given scalar.
        Specified by:
        div in class AbstractJavaPoint<JavaPoint2D>
        Parameters:
        scalar - The scalar to by which this should be divided
        Returns:
        A new instance holding the result of the division
      • dot

        public double dot​(JavaPoint2D vector)
        Computes the dot product of this and the given JavaPoint.
        Specified by:
        dot in class AbstractJavaPoint<JavaPoint2D>
        Parameters:
        vector - The JavaPoint to be multiplied by this
        Returns:
        A new instance holding the result of the multiplication
      • cross

        public double cross​(JavaPoint2D vector)
        Computes the 2D pseudo cross product Dot(Perp(this), JavaPoint) of this and the given JavaPoint.
        Parameters:
        vector - The JavaPoint to be multiplied to the perpendicular vector of this
        Returns:
        A new instance holding the result of the pseudo cross product
      • rotate

        public JavaPoint2D rotate​(double radians,
                                  JavaPoint2D origin)
        Rotates a Java Point around a given origin
        Parameters:
        radians - the radians to rotate the point
        origin - the origin where the point is rotated around
        Returns:
        the resulting rotated point