java.lang.Object
imagingbook.common.geometry.basic.Pnt2d.PntDouble
- All Implemented Interfaces:
Pnt2d,Primitive2d,ShapeProducer
- Enclosing interface:
Pnt2d
Immutable 2D point implementation with
double coordinates. This class implements the Pnt2d
interface. A protected constructor is provided but the preferred way of instantiation is by one of the static
factory methods, such as from(double, double), from(double[]), etc. Access to the coordinate
values is provided by the methods getX() and getY(), but the actual field variables x,
y are also publicly accessible (for better performance and less clutter).-
Nested Class Summary
Nested classes/interfaces inherited from interface imagingbook.common.geometry.basic.Pnt2d
Pnt2d.PntDouble, Pnt2d.PntInt -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal doubleThe (immutable) x-coordinate of this pointfinal doubleThe (immutable) y-coordinate of this pointstatic final Pnt2d.PntDoubleSingleton point instance with zero coordinates.Fields inherited from interface imagingbook.common.geometry.basic.Pnt2d
DefaultDotRadius, TOLERANCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of this point which is of the same type as the original.booleanstatic Pnt2d.PntDoublefrom(double[] xy) Returns a newPnt2d.PntDoubleinstance.static Pnt2d.PntDoublefrom(double x, double y) Returns a newPnt2d.PntDoubleinstance.static Pnt2d.PntDoubleReturns a newPnt2d.PntDoubleinstance with the same coordinates as the given point.static Pnt2d.PntDoubleReturns a newPnt2d.PntDoubleinstance with the same coordinates as the given AWTPoint2D.static Pnt2d.PntDoubleReturns a newPnt2d.PntDoubleinstance with the same coordinates as the given Apache Commons MathVector2D.doublegetX()Returns the x-coordinate of this point.intgetXint()Returns the x-coordinate of this point as a (truncated) integer value.doublegetY()Returns the y-coordinate of this point.intgetYint()Returns the y-coordinate of this point as a (truncated) integer value.inthashCode()Returns a new point whose coordinates are the difference of this point and the given point.plus(double dx, double dy) Returns a new point whose coordinates are the sum of this point and the specifieddoublecoordinates.toString()The number of output digits is specified by the current settings ofPrintPrecision.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface imagingbook.common.geometry.basic.Pnt2d
cross, distance, distanceSq, distL1, distL2, dot, equals, getDistance, getShape, minus, mult, perp, plus, toAwtPoint2D, toDoubleArray, toRealVector, toVector2DMethods inherited from interface imagingbook.common.geometry.shape.ShapeProducer
getShape, getShapes, getShapes
-
Field Details
-
ZERO
Singleton point instance with zero coordinates. -
x
The (immutable) x-coordinate of this point -
y
The (immutable) y-coordinate of this point
-
-
Constructor Details
-
PntDouble
Constructor.- Parameters:
x- x-coordinatey- y-coordinate
-
-
Method Details
-
duplicate
Description copied from interface:Pnt2dReturns a copy of this point which is of the same type as the original. -
from
Returns a newPnt2d.PntDoubleinstance.- Parameters:
xy- x/y-coordinate array- Returns:
- the new point
-
from
Returns a newPnt2d.PntDoubleinstance.- Parameters:
x- x-coordinate valuey- y-coordinate value- Returns:
- the new point
-
from
Returns a newPnt2d.PntDoubleinstance with the same coordinates as the given point. Equivalent toduplicate().- Parameters:
p- the original point- Returns:
- the new point
-
from
Returns a newPnt2d.PntDoubleinstance with the same coordinates as the given AWTPoint2D.- Parameters:
p- the original AWT point- Returns:
- the new point
-
from
Returns a newPnt2d.PntDoubleinstance with the same coordinates as the given Apache Commons MathVector2D.- Parameters:
vec- the original coordinate vector- Returns:
- the new point
-
getX
Description copied from interface:Pnt2dReturns the x-coordinate of this point. -
getY
Description copied from interface:Pnt2dReturns the y-coordinate of this point. -
getXint
Description copied from interface:Pnt2dReturns the x-coordinate of this point as a (truncated) integer value. -
getYint
Description copied from interface:Pnt2dReturns the y-coordinate of this point as a (truncated) integer value. -
plus
Description copied from interface:Pnt2dReturns a new point whose coordinates are the sum of this point and the specifieddoublecoordinates. -
minus
Description copied from interface:Pnt2dReturns a new point whose coordinates are the difference of this point and the given point. -
equals
-
toString
The number of output digits is specified by the current settings ofPrintPrecision. UsePrintPrecision.set(int)orPrintPrecision.reset()to change. -
hashCode
-