Class JavaPoint2D
- java.lang.Object
-
- science.aist.imaging.api.domain.AbstractJavaPoint<JavaPoint2D>
-
- science.aist.imaging.api.domain.twodimensional.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
-
-
Field Summary
-
Fields inherited from class science.aist.imaging.api.domain.AbstractJavaPoint
x, y, z
-
-
Constructor Summary
Constructors Constructor Description JavaPoint2D(double x, double y)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JavaPoint2D
add(JavaPoint2D vector)
Adds the given JavaPoint to this.protected JavaPoint2D
calculateUnify()
double
cross(JavaPoint2D vector)
Computes the 2D pseudo cross product Dot(Perp(this), JavaPoint) of this and the given JavaPoint.JavaPoint2D
div(double scalar)
Divides this by the given scalar.double
dot(JavaPoint2D vector)
Computes the dot product of this and the given JavaPoint.boolean
equals(Object o)
int
hashCode()
JavaPoint2D
mult(double scalar)
Multiplies this by the given scalar.JavaPoint2D
mult(JavaPoint2D vector)
Multiplies this by the given vector.JavaPoint2D
rotate(double radians)
Rotates a Java Point around the origin (0, 0)JavaPoint2D
rotate(double radians, JavaPoint2D origin)
Rotates a Java Point around a given originJavaPoint2D
sub(JavaPoint2D vector)
Subtracts the given JavaPoint from this.-
Methods inherited from class science.aist.imaging.api.domain.AbstractJavaPoint
equals, getIntX, getIntY, getIntZ, pointDistance, positionalEqual, positionalEqual, xDistance, yDistance, zDistance
-
-
-
-
Method Detail
-
sub
public JavaPoint2D sub(JavaPoint2D vector)
Subtracts the given JavaPoint from this.- Specified by:
sub
in classAbstractJavaPoint<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 classAbstractJavaPoint<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 classAbstractJavaPoint<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 classAbstractJavaPoint<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 classAbstractJavaPoint<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 classAbstractJavaPoint<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)
Rotates a Java Point around the origin (0, 0)- Parameters:
radians
- the radians to rotate the point- Returns:
- the resulting rotated point
- See Also:
- https://en.wikipedia.org/wiki/Rotation_matrix#In_two_dimensions
-
rotate
public JavaPoint2D rotate(double radians, JavaPoint2D origin)
Rotates a Java Point around a given origin- Parameters:
radians
- the radians to rotate the pointorigin
- the origin where the point is rotated around- Returns:
- the resulting rotated point
-
calculateUnify
protected JavaPoint2D calculateUnify()
- Specified by:
calculateUnify
in classAbstractJavaPoint<JavaPoint2D>
- Returns:
- Returns a new instance holding the unit vector of this
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classAbstractJavaPoint<JavaPoint2D>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractJavaPoint<JavaPoint2D>
-
-