Package science.aist.imaging.api.domain
Class AbstractJavaPoint<T extends AbstractJavaPoint<T>>
- java.lang.Object
-
- science.aist.imaging.api.domain.AbstractJavaPoint<T>
-
- Type Parameters:
T
- The type of the point
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JavaPoint2D
,JavaPoint3D
public abstract class AbstractJavaPoint<T extends AbstractJavaPoint<T>> extends Object implements Serializable
Base class of JavaPoint
- Since:
- 1.0
- Author:
- Christoph Praschl
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractJavaPoint()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract T
add(T vector)
Adds the given JavaPoint to this.protected abstract T
calculateUnify()
abstract T
div(double scalar)
Divides this by the given scalar.abstract double
dot(T vector)
Computes the dot product of this and the given JavaPoint.boolean
equals(Object o)
boolean
equals(Object o, double epsilon)
Equality check with epsilon for coordinatesint
getIntX()
Returns the rounded int valueint
getIntY()
Returns the rounded int valueint
getIntZ()
Returns the rounded int valueint
hashCode()
abstract T
mult(double scalar)
Multiplies this by the given scalar.abstract T
mult(T vector)
Multiplies this by the given vector.static double
pointDistance(AbstractJavaPoint<?> p1, AbstractJavaPoint<?> p2)
returns the 3D distance between two given points sqrt((point1.x - point2.x)^2 + (point1.y - point2.y)^2 + (point1.z - point2.z)^2)boolean
positionalEqual(T that)
Checks if this and that are positional equal (not type equal)boolean
positionalEqual(T that, double epsilon)
Checks if this and that are positional equal (not type equal)abstract T
sub(T vector)
Subtracts the given JavaPoint from this.static double
xDistance(AbstractJavaPoint<?> p1, AbstractJavaPoint<?> p2)
returns the absolute distance in x direction between two points.static double
yDistance(AbstractJavaPoint<?> p1, AbstractJavaPoint<?> p2)
returns the absolute distance in y direction between two points.static double
zDistance(AbstractJavaPoint<?> p1, AbstractJavaPoint<?> p2)
returns the absolute distance in x direction between two points.
-
-
-
Method Detail
-
pointDistance
public static double pointDistance(AbstractJavaPoint<?> p1, AbstractJavaPoint<?> p2)
returns the 3D distance between two given points sqrt((point1.x - point2.x)^2 + (point1.y - point2.y)^2 + (point1.z - point2.z)^2)- Parameters:
p1
- point1p2
- point2- Returns:
- the distance between two given points
-
xDistance
public static double xDistance(AbstractJavaPoint<?> p1, AbstractJavaPoint<?> p2)
returns the absolute distance in x direction between two points. abs(point1.x - point2.x)- Parameters:
p1
- point1p2
- point2- Returns:
- distance in x direction
-
yDistance
public static double yDistance(AbstractJavaPoint<?> p1, AbstractJavaPoint<?> p2)
returns the absolute distance in y direction between two points. abs(point1.y - point2.y)- Parameters:
p1
- point1p2
- point2- Returns:
- distance in y direction
-
zDistance
public static double zDistance(AbstractJavaPoint<?> p1, AbstractJavaPoint<?> p2)
returns the absolute distance in x direction between two points. abs(point1.x - point2.x)- Parameters:
p1
- point1p2
- point2- Returns:
- distance in x direction
-
getIntX
public int getIntX()
Returns the rounded int value- Returns:
- rounded x-coordinate
-
getIntY
public int getIntY()
Returns the rounded int value- Returns:
- rounded y-coordinate
-
getIntZ
public int getIntZ()
Returns the rounded int value- Returns:
- rounded z-coordinate
-
sub
public abstract T sub(T vector)
Subtracts the given JavaPoint from this.- Parameters:
vector
- The JavaPoint to be subtracted from this- Returns:
- A new instance holding the result of the vector subtraction
-
add
public abstract T add(T vector)
Adds the given JavaPoint to this.- Parameters:
vector
- The JavaPoint to be added to this- Returns:
- A new instance holding the result of the vector addition
-
mult
public abstract T mult(double scalar)
Multiplies this by the given scalar.- Parameters:
scalar
- The scalar to be multiplied by this- Returns:
- A new instance holding the result of the multiplication
-
mult
public abstract T mult(T vector)
Multiplies this by the given vector.- Parameters:
vector
- The vector to be multiplied by this- Returns:
- A new instance holding the result of the multiplication
-
div
public abstract T div(double scalar)
Divides this by the given scalar.- Parameters:
scalar
- The scalar to by which this should be divided- Returns:
- A new instance holding the result of the division
-
dot
public abstract double dot(T vector)
Computes the dot product of this and the given JavaPoint.- Parameters:
vector
- The JavaPoint to be multiplied by this- Returns:
- A new instance holding the result of the multiplication
-
calculateUnify
protected abstract T calculateUnify()
- Returns:
- Returns a new instance holding the unit vector of this
-
equals
public boolean equals(Object o, double epsilon)
Equality check with epsilon for coordinates- Parameters:
o
- other objectepsilon
- epsilon used for coordinate comparison- Returns:
- true iff this and o are equal with the given epsilon; else false
-
positionalEqual
public boolean positionalEqual(T that)
Checks if this and that are positional equal (not type equal)- Parameters:
that
- other point- Returns:
- true iff this and that are not null and positional equal; else false
-
positionalEqual
public boolean positionalEqual(T that, double epsilon)
Checks if this and that are positional equal (not type equal)- Parameters:
that
- other pointepsilon
- epsilon used for coordinate comparison- Returns:
- true iff this and that are not null and positional equal; else false
-
-