Modifier and Type | Field and Description |
---|---|
static PointD |
ORIGIN
|
double |
x
Gets the X coordinate of the point.
|
double |
y
Gets the Y coordinate of the point.
|
Constructor and Description |
---|
PointD() |
PointD(double x,
double y)
|
PointD(IPoint point)
Initializes a new instance using the coordinates of the provided
IPoint . |
Modifier and Type | Method and Description |
---|---|
static PointD |
add(PointD p1,
PointD p2)
Implements the vector addition operator.
|
PointD |
clone() |
static PointD |
convertFrom(MutablePoint p)
Performs an explicit conversion from
MutablePoint to PointD . |
static MutablePoint |
convertToMutablePoint(PointD point)
Performs an implicit conversion from
PointD to MutablePoint . |
double |
distanceTo(PointD other)
Calculates the Euclidean distance to the given point.
|
double |
distanceToSegment(PointD start,
PointD end)
Determines the distance between this point and a line segment.
|
boolean |
equals(Object other)
Indicates whether this instance and a specified object are equal.
|
static boolean |
equals(PointD p1,
PointD p2)
|
boolean |
equalsEps(PointD other,
double eps)
Determines whether the two given points have the same coordinates with respect to a certain given
eps . |
PointD |
getConstrained(RectD rectangle)
Create a constrained copy of this instance that lies within the given non-empty
rectangle . |
PointD |
getNormalized()
Gets the normalized version of this vector.
|
PointD |
getProjectionOnLine(PointD anchor,
PointD direction)
Calculates the projection of this point onto a line.
|
PointD |
getProjectionOnRay(PointD rayStart,
PointD direction)
Calculates the projection of this point onto a ray.
|
PointD |
getProjectionOnSegment(PointD start,
PointD end)
Calculates the projection of this point onto a segment.
|
double |
getSquaredVectorLength()
|
double |
getVectorLength()
|
double |
getX()
Gets or sets the X coordinate of the point.
|
double |
getY()
Gets or sets the Y coordinate of the point.
|
int |
hashCode()
|
boolean |
hits(PointD other,
double hitTestRadius)
Determines if the point lies close to this point given an epsilon.
|
boolean |
hitsLineSegment(PointD start,
PointD end,
double radius)
Determines whether this point hits the line segment with respect to a given
radius . |
boolean |
hitsPolyline(Iterable<IPoint> points,
double radius)
Determines whether a polygonal line is hit by this point given an epsilon.
|
boolean |
isHorizontalVector()
Indicates whether this instance is a horizontally oriented vector.
|
boolean |
isVerticalVector()
Indicates whether this instance is a vertically oriented vector.
|
static PointD |
multiply(Matrix2D matrix,
PointD vector)
Implements the vector transformation by calling
Matrix2D.transform(PointD) . |
static PointD |
multiply(PointD point,
double factor)
Implements scalar multiplication.
|
double |
scalarProduct(PointD other)
Calculates the scalar product of this and the given vector.
|
static double |
scalarProduct(PointD point1,
PointD point2)
Calculates the scalar product of the two given points.
|
static PointD |
subtract(PointD p1,
PointD p2)
Implements the vector subtraction operator.
|
IMutablePoint |
toMutablePoint()
Creates an
IMutablePoint that has the same coordinates as this struct. |
PointD |
toPointD()
Copies the current values of the coordinates of the point to a
PointD struct. |
String |
toString()
Returns a human readable string of this point.
|
finalize, getClass, notify, notifyAll, wait, wait, wait
distanceTo
public static final PointD ORIGIN
public final double x
public final double y
public PointD()
public PointD(double x, double y)
x
- The x coordinate.y
- The y coordinate.public static final PointD add(PointD p1, PointD p2)
p1
- The first point.p2
- The second point.public static final PointD convertFrom(MutablePoint p)
MutablePoint
to PointD
.p
- The point to convert.public static final MutablePoint convertToMutablePoint(PointD point)
PointD
to MutablePoint
.point
- The point to convert.public final double distanceTo(PointD other)
other
- The other point.public final double distanceToSegment(PointD start, PointD end)
start
- The coordinates of the first point of the line.end
- The coordinates of the second point of the line.public boolean equals(Object other)
public final boolean equalsEps(PointD other, double eps)
eps
.other
- The other point to check for equality against this point.eps
- The epsilon value.public final PointD getConstrained(RectD rectangle)
rectangle
.
If the given rectangle is RectD.EMPTY
, this implementation will silently return.
rectangle
- The rectangle to constrain this instance by.public final PointD getNormalized()
(1,0)
if this vector has 0.0d
length.public final PointD getProjectionOnLine(PointD anchor, PointD direction)
anchor
- An anchor for the infinite line.direction
- A direction vector for the infinite line.public final PointD getProjectionOnRay(PointD rayStart, PointD direction)
If the perpendicular projection onto the line is outside of the ray ("behind" the rayStart
) the rayStart
is returned instead.
rayStart
- The start of the segment.direction
- The direction of the ray.public final PointD getProjectionOnSegment(PointD start, PointD end)
If the perpendicular projection onto the line is outside of the segment the nearest segment endpoint is returned.
start
- The start of the segment.end
- The end of the segment.public final double getSquaredVectorLength()
X*X + Y*Y
.public final double getVectorLength()
X*X + Y*Y
.public final double getX()
public final double getY()
public int hashCode()
public final boolean hits(PointD other, double hitTestRadius)
other
- The coordinates of the other point.hitTestRadius
- The hit test epsilon.hitTestRadius
public final boolean hitsLineSegment(PointD start, PointD end, double radius)
radius
.start
- The starting point of the line segment to test.end
- The ending point of the line segment to test.radius
- The hit test radius.public final boolean hitsPolyline(Iterable<IPoint> points, double radius)
points
- The list of points that is treated as a polygonradius
- A positive value allows for fuzzy hit testing. If the point lies outside the given object but it's distance is less than
or equal to that value, it will be considered a hit.public final boolean isHorizontalVector()
true
iff Math.Abs(X) > Math.Abs(Y)
.public final boolean isVerticalVector()
true
iff Math.Abs(Y) > Math.Abs(X)
.public static final PointD multiply(Matrix2D matrix, PointD vector)
Matrix2D.transform(PointD)
.matrix
- The matrix to use for the transformation.vector
- The vector to transform.public static final PointD multiply(PointD point, double factor)
point
- The point to scale the components of.factor
- The factor to scale the components by.public final double scalarProduct(PointD other)
other
- The other vector.X*other.X + Y*other.Y
)public static final double scalarProduct(PointD point1, PointD point2)
point1
- The first point.point2
- The second point.public static final PointD subtract(PointD p1, PointD p2)
p1
- The first point.p2
- The second point.public final IMutablePoint toMutablePoint()
IMutablePoint
that has the same coordinates as this struct.IMutablePoint
with the same coordinates.public PointD toPointD()
IPoint
PointD
struct.
This method is useful to obtain a copy of the state and for making use of the various utility methods that are provided
by PointD
.
toPointD
in interface IPoint
toMutablePoint()
,
IMutablePoint.relocate(PointD)