java.lang.Object
imagingbook.common.geometry.basic.Pnt2d.PntInt
- All Implemented Interfaces:
Pnt2d,Primitive2d,ShapeProducer
- Direct Known Subclasses:
LocalMinMaxFinder.ExtremalPoint,PixelMap.Pixel
- Enclosing interface:
Pnt2d
Immutable 2D point implementation with
int 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(int, int), from(int[]), etc. The int coordinates can only
be retrieved via the publicly accessible field variables x, y, while the methods
getX() and getY() return double values for compatibility reasons.-
Nested Class Summary
Nested classes/interfaces inherited from interface imagingbook.common.geometry.basic.Pnt2d
Pnt2d.PntDouble, Pnt2d.PntInt -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intThe (immutable) x-coordinate of this pointfinal intThe (immutable) y-coordinate of this pointstatic final Pnt2d.PntIntSingleton point instance with zero coordinates.Fields inherited from interface imagingbook.common.geometry.basic.Pnt2d
DefaultDotRadius, TOLERANCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintdistanceSq(Pnt2d.PntInt other) Returns the squared L2 distance between this point and the given point.intReturns the L1 (Manhattan) distance between this point and the given point.Returns a copy of this point which is of the same type as the original.booleanstatic Pnt2d.PntIntfrom(int[] xy) Returns a newPnt2d.PntIntinstance.static Pnt2d.PntIntfrom(int x, int y) Returns a newPnt2d.PntIntinstance.static Pnt2d.PntIntReturns a newPnt2d.PntIntfrom a givenPnt2dinstance.static Pnt2d.PntIntfrom(Pnt2d.PntInt p) Returns a newPnt2d.PntIntinstance from a given point.static Pnt2d.PntIntReturns a newPnt2d.PntDoubleinstance with the same coordinates as the given AWTPoint.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()minus(int dx, int dy) Returns a new point whose coordinates are the difference of this point and the given point.plus(int[] dxy) plus(int dx, int dy) Returns a new point whose coordinates are the sum of this point and the given point.plus(Pnt2d.PntInt p) Returns this point's coordinates as a new AWTPointpoint.int[]Returns this point's coordinates as a new 2-elementintarray.toString()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
-
PntInt
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.PntIntinstance from a given point.- Parameters:
p- the original point- Returns:
- the new point
-
from
Returns a newPnt2d.PntIntinstance.- Parameters:
x- x-coordinate valuey- y-coordinate value- Returns:
- the new point
-
from
Returns a newPnt2d.PntIntinstance.- Parameters:
xy- x/y-coordinates- Returns:
- the new point
-
from
Returns a newPnt2d.PntIntfrom a givenPnt2dinstance. This only works if the argument is of typePnt2d.PntInt, otherwise an exception is thrown.- Parameters:
p- a point of typePnt2d.PntInt- Returns:
- the new point
-
from
Returns a newPnt2d.PntDoubleinstance with the same coordinates as the given AWTPoint.- Parameters:
p- the original AWT point- 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
-
plus
-
plus
-
plus
Description copied from interface:Pnt2dReturns a new point whose coordinates are the sum of this point and the given point. The concrete type of the returned object depends on the type of the original points. -
minus
-
minus
-
minus
Description copied from interface:Pnt2dReturns a new point whose coordinates are the difference of this point and the given point. -
distL1
Returns the L1 (Manhattan) distance between this point and the given point.- Parameters:
p- the other point- Returns:
- the distance
-
distanceSq
Returns the squared L2 distance between this point and the given point.- Parameters:
other- the other point- Returns:
- the squared distance
-
equals
-
toString
-
hashCode
-
toIntArray
Returns this point's coordinates as a new 2-elementintarray.- Returns:
- the array
-
toAwtPoint
Returns this point's coordinates as a new AWTPointpoint.- Returns:
- the new point
-