Package ome.util.math.geom2D
Class PlanePoint
- java.lang.Object
-
- ome.util.math.geom2D.PlanePoint
-
public class PlanePoint extends java.lang.ObjectRepresents 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
-
-
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 doubleangle(PlanePoint vec)Calculates the angle between this vector and the specified argument, provided none of these vectors is the null vector.PlanePointdiff(PlanePoint vec)Calculates the sum of this vector with the reciprocal of the specified argument.doubledistance(PlanePoint p)Calculates the distance between this point and the specified argument.doubledot(PlanePoint vec)Calulates the dot product of this vector by the specified argument.booleanequals(double x1, double x2)Check to see if the point values are equal.booleanequals(java.lang.Object o)Overridden to reflect equality of abstract values (data object) as opposite to object identity.inthashCode()Overridden to reflect equality of abstract values (data object) as opposite to object identity.doublenorm()Calculates the Euclidian norm of this vector.PlanePointnormalize()Calculates the unit vector of this vector, provided this is not the null vector.PlanePointscalar(double k)Multiplies this vector by the specified scalar.PlanePointsum(PlanePoint vec)Calculates the sum of this vector with the specified argument.PlanePointvec(double x1, double x2)Calculates the vector associated to this point and the specified argument.PlanePointvec(PlanePoint p)Calculates the vector associated to this point and the specified argument.
-
-
-
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, ifA=(a1, b1) andB=(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 benull.- 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 anullreference.- 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 elementv=(x1, x2) of R2 is given by-v=(-x1, -x2) .- Parameters:
vec- The other vector. Mustn't be anullreference.- 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:
This method returnsf: AxA ---> V
f(a, b) = b - a = (b1 - a1, b2 - a2)f(t, p) , where t is this point and p is the specified argument.- Parameters:
p- The other point. Mustn't be anullreference.- 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:
This method returnsf: AxA ---> V
f(a, b) = b - a = (b1 - a1, b2 - a2)f(t, p) , where t is this point and p is the specified argument.- Parameters:
x1- The first element of the pointx2- 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, ifv=(v1, v2) andw=(w1, w2) are two vectors of R2, then the dot product is defined byv1*w1 + v2*w2 .- Parameters:
vec- The other vector in the product. Mustn't be anullreference.- Returns:
- The dot product.
-
norm
public double norm()
Calculates the Euclidian norm of this vector. That is, the square root of thedotproduct 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 byt / ||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 anullreference and mustn't be the null vector.- Returns:
- The angle between this vector and
vec, in the range of0throughpi. - Throws:
java.lang.IllegalArgumentException- If this vector orvecor 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:
equalsin classjava.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:
trueif the points are equal,falseotherwise.
-
hashCode
public int hashCode()
Overridden to reflect equality of abstract values (data object) as opposite to object identity.- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
-