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 double
The (immutable) x-coordinate of this pointfinal double
The (immutable) y-coordinate of this pointstatic final Pnt2d.PntDouble
Singleton 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.boolean
static Pnt2d.PntDouble
from
(double[] xy) Returns a newPnt2d.PntDouble
instance.static Pnt2d.PntDouble
from
(double x, double y) Returns a newPnt2d.PntDouble
instance.static Pnt2d.PntDouble
Returns a newPnt2d.PntDouble
instance with the same coordinates as the given point.static Pnt2d.PntDouble
Returns a newPnt2d.PntDouble
instance with the same coordinates as the given AWTPoint2D
.static Pnt2d.PntDouble
Returns a newPnt2d.PntDouble
instance with the same coordinates as the given Apache Commons MathVector2D
.double
getX()
Returns the x-coordinate of this point.int
getXint()
Returns the x-coordinate of this point as a (truncated) integer value.double
getY()
Returns the y-coordinate of this point.int
getYint()
Returns the y-coordinate of this point as a (truncated) integer value.int
hashCode()
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 specifieddouble
coordinates.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, wait
Methods inherited from interface imagingbook.common.geometry.basic.Pnt2d
cross, distance, distanceSq, distL1, distL2, dot, equals, getDistance, getShape, minus, mult, perp, plus, toAwtPoint2D, toDoubleArray, toRealVector, toVector2D
Methods 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:Pnt2d
Returns a copy of this point which is of the same type as the original. -
from
Returns a newPnt2d.PntDouble
instance.- Parameters:
xy
- x/y-coordinate array- Returns:
- the new point
-
from
Returns a newPnt2d.PntDouble
instance.- Parameters:
x
- x-coordinate valuey
- y-coordinate value- Returns:
- the new point
-
from
Returns a newPnt2d.PntDouble
instance with the same coordinates as the given point. Equivalent toduplicate()
.- Parameters:
p
- the original point- Returns:
- the new point
-
from
Returns a newPnt2d.PntDouble
instance with the same coordinates as the given AWTPoint2D
.- Parameters:
p
- the original AWT point- Returns:
- the new point
-
from
Returns a newPnt2d.PntDouble
instance 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:Pnt2d
Returns the x-coordinate of this point. -
getY
Description copied from interface:Pnt2d
Returns the y-coordinate of this point. -
getXint
Description copied from interface:Pnt2d
Returns the x-coordinate of this point as a (truncated) integer value. -
getYint
Description copied from interface:Pnt2d
Returns the y-coordinate of this point as a (truncated) integer value. -
plus
Description copied from interface:Pnt2d
Returns a new point whose coordinates are the sum of this point and the specifieddouble
coordinates. -
minus
Description copied from interface:Pnt2d
Returns 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
-