Class PlanePoint


  • public class PlanePoint
    extends java.lang.Object
    Represents a point in the Euclidean space R2.

    Because this space is built on the vector space R2, any instance of this class also represents a vector in R2. Moreover, unless otherwise stated, we assume the orthonormal frame {O, e1, e2} where O=(0,0), e1=(1, 0), e2=(0, 1).

    Since:
    OME2.2
    • Field Summary

      Fields 
      Modifier and Type Field Description
      double x1
      The first element.
      double x2
      The second element.
    • Constructor Summary

      Constructors 
      Constructor Description
      PlanePoint​(double x1, double x2)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double angle​(PlanePoint vec)
      Calculates the angle between this vector and the specified argument, provided none of these vectors is the null vector.
      PlanePoint diff​(PlanePoint vec)
      Calculates the sum of this vector with the reciprocal of the specified argument.
      double distance​(PlanePoint p)
      Calculates the distance between this point and the specified argument.
      double dot​(PlanePoint vec)
      Calulates the dot product of this vector by the specified argument.
      boolean equals​(double x1, double x2)
      Check to see if the point values are equal.
      boolean equals​(java.lang.Object o)
      Overridden to reflect equality of abstract values (data object) as opposite to object identity.
      int hashCode()
      Overridden to reflect equality of abstract values (data object) as opposite to object identity.
      double norm()
      Calculates the Euclidian norm of this vector.
      PlanePoint normalize()
      Calculates the unit vector of this vector, provided this is not the null vector.
      PlanePoint scalar​(double k)
      Multiplies this vector by the specified scalar.
      PlanePoint sum​(PlanePoint vec)
      Calculates the sum of this vector with the specified argument.
      PlanePoint vec​(double x1, double x2)
      Calculates the vector associated to this point and the specified argument.
      PlanePoint vec​(PlanePoint p)
      Calculates the vector associated to this point and the specified argument.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • x1

        public final double x1
        The first element.
      • x2

        public final double x2
        The second element.
    • Constructor Detail

      • PlanePoint

        public PlanePoint​(double x1,
                          double x2)
        Creates a new instance.
        Parameters:
        x1 - The first element of the point
        x2 - The second element of the point
    • Method Detail

      • distance

        public double distance​(PlanePoint p)
        Calculates the distance between this point and the specified argument. We use the standard distance of two points in the Euclidean space R2. That is, if A=(a1, b1) and B=(a2, b2) are two points of R2, then the distance is defined by the square root of (a1 - a2)2 + (b1 - b2)2 .
        Parameters:
        p - The other point. Mustn't be null.
        Returns:
        The distance between this point and p.
      • sum

        public PlanePoint sum​(PlanePoint vec)
        Calculates the sum of this vector with the specified argument. This is the standard sum of two vectors in the R2 group and is given by the sum of their components.
        Parameters:
        vec - The other vector. Mustn't be a null reference.
        Returns:
        The sum of this vector with vec.
      • diff

        public PlanePoint diff​(PlanePoint vec)
        Calculates the sum of this vector with the reciprocal of the specified argument. The sum is the standard sum of two vectors in the R2 group — the sum of their components. Under this sum, the reciprocal of an element v=(x1, x2) of R2 is given by -v=(-x1, -x2).
        Parameters:
        vec - The other vector. Mustn't be a null reference.
        Returns:
        The sum of this vector with -vec.
      • scalar

        public PlanePoint scalar​(double k)
        Multiplies this vector by the specified scalar. This is the standard scalar multiplication in the vector space R2, which is done by multiplying each component by the specified scalar.
        Parameters:
        k - The scalar.
        Returns:
        The vector obtained by multiplying this vector by k.
      • vec

        public PlanePoint vec​(PlanePoint p)
        Calculates the vector associated to this point and the specified argument. This is the map that makes the set A = R2 an affine space over the vector space V = R2 and is defined by:

        f: AxA ---> V
        f(a, b) = b - a = (b1 - a1, b2 - a2)

        This method returns f(t, p), where t is this point and p is the specified argument.
        Parameters:
        p - The other point. Mustn't be a null reference.
        Returns:
        The vector associated to this point and p.
      • vec

        public PlanePoint vec​(double x1,
                              double x2)
        Calculates the vector associated to this point and the specified argument. This is the map that makes the set A = R2 an affine space over the vector space V = R2 and is defined by:

        f: AxA ---> V
        f(a, b) = b - a = (b1 - a1, b2 - a2)

        This method returns f(t, p), where t is this point and p is the specified argument.
        Parameters:
        x1 - The first element of the point
        x2 - The second element of the point
        Returns:
        The vector associated to this point and p.
      • dot

        public double dot​(PlanePoint vec)
        Calulates the dot product of this vector by the specified argument. We use the standard dot product of two vectors in R2. That is, if v=(v1, v2) and w=(w1, w2) are two vectors of R2, then the dot product is defined by v1*w1 + v2*w2.
        Parameters:
        vec - The other vector in the product. Mustn't be a null reference.
        Returns:
        The dot product.
      • norm

        public double norm()
        Calculates the Euclidian norm of this vector. That is, the square root of the dot product of this vector by itself.
        Returns:
        The norm of this vector.
      • normalize

        public PlanePoint normalize()
        Calculates the unit vector of this vector, provided this is not the null vector. If this is not the null vector, then the returned vector is given by t / ||t||, where t is this vector and ||t|| is its norm. Otherwise we return the null vector.
        Returns:
        A unit vector if this is not the null vector, the null vector otherwise.
      • angle

        public double angle​(PlanePoint vec)
        Calculates the angle between this vector and the specified argument, provided none of these vectors is the null vector. We use the standard definition of an angle between two non-null vectors. This is given by the arc cosine of the dot product of the two vectors divided by the product of their norms: acos(v.w / ||v||*||w||). If any of the two vectors is the null vector we throw an exception.
        Parameters:
        vec - The other vector. Mustn't be a null reference and mustn't be the null vector.
        Returns:
        The angle between this vector and vec, in the range of 0 through pi.
        Throws:
        java.lang.IllegalArgumentException - If this vector or vec or both are the null vector.
      • equals

        public boolean equals​(java.lang.Object o)
        Overridden to reflect equality of abstract values (data object) as opposite to object identity.
        Overrides:
        equals in class java.lang.Object
        See Also:
        Object.equals(Object)
      • equals

        public boolean equals​(double x1,
                              double x2)
        Check to see if the point values are equal.
        Parameters:
        x1 - The comparison point's first element.
        x2 - The comparison point's second element.
        Returns:
        true if the points are equal, false otherwise.
      • hashCode

        public int hashCode()
        Overridden to reflect equality of abstract values (data object) as opposite to object identity.
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Object.hashCode()