public class GeometryUtils
extends java.lang.Object
| Constructor and Description |
|---|
GeometryUtils() |
| Modifier and Type | Method and Description |
|---|---|
static double |
findNearestPoint(Point3d pr,
java.util.List<Point3d> vtxs,
boolean closed,
Point3d p0,
double r0)
Finds the nearest point on a polyline to a prescribed point
p0. |
static double |
findPointAtDistance(java.util.List<Point3d> vtxs,
boolean closed,
double ra,
double rb,
Point3d p0,
double dist,
double tol)
Finds the point, if any, within a segment on a polyline that is a
specified distance
dist from a prescribed point p0,
within a tolerance tol. |
static double |
findPointAtDistance(Point3d pr,
java.util.List<Point3d> vtxs,
boolean closed,
Point3d p0,
double dist,
double r0)
Finds the point on a polyline that is a specified distance
dist
from a prescribed point p0, within machine precision. |
static double |
findPointAtDistance(Point3d pr,
java.util.List<Point3d> vtxs,
boolean closed,
Point3d p0,
double dist,
double r0,
boolean reverse) |
static double |
findPointAtDistanceOld(Point3d pr,
java.util.List<Point3d> vtxs,
boolean closed,
Point3d p0,
double dist,
double r0,
boolean reverse)
Finds the point on a polyline that is a specified distance
dist
from a prescribed point p0, within machine precision. |
static double |
getCharacteristicLength(java.util.Collection<Point3d> pnts)
Finds the characteristic length of a collection of points.
|
static Point3d |
getPointAt(double r,
java.util.List<Point3d> vtxs,
boolean closed)
Gets a point at a specific location on a polyline.
|
public static double getCharacteristicLength(java.util.Collection<Point3d> pnts)
pnts - points to querypublic static double findPointAtDistance(Point3d pr, java.util.List<Point3d> vtxs, boolean closed, Point3d p0, double dist, double r0)
dist
from a prescribed point p0, within machine precision. Equivalent
to calling findPointAtDistance(Point3d,List,boolean,Point3d,
double,double,boolean) with reverse set to false.pr - if not null, returns the distance point, if foundvtxs - list of vertices defining the polylineclosed - true if the polyline is closedp0 - point with respect to which distance should be determineddist - desired distance from p0r0 - for open polylines, a non-negative scalar giving the location
on the polyline where the search should start. This should be a
non-negative scalar whose value is less than or equal to the number of
polyline intervals, which will be vtxs.size()-1.public static double findPointAtDistanceOld(Point3d pr, java.util.List<Point3d> vtxs, boolean closed, Point3d p0, double dist, double r0, boolean reverse)
dist
from a prescribed point p0, within machine precision. The
polyline is specified by a list of vertices vtxs. Point locations
on the polyline are described by a non-negative location parameter r, which takes the form described in the documentation for getPointAt(double, java.util.List<maspack.matrix.Point3d>, boolean). If the polyline is open, the search for the distance point
begins at a location specified by r0. By default, the search
proceeds forward (toward larger r) and locations before r0 are ignored. If reverse is true, the search instead
proceeds backward (toward smaller r) and locations after r0 are ignored; if the search reaches the beginning of the polyline
without finding a point at distance dist from p0, -1 is
returned. If the polyline is closed, r0 and reverse are
both ignored.
If found, the method will return the point's location parameter r, as well as the point's value in the optional parameter pr if
it is not null. If the point is not found, the method will return
-1.
It is assumed that no two adjacent vertices on the polyline are identical within machine precision. If they are, an exception will be thrown.
pr - if not null, returns the distance point, if foundvtxs - list of vertices defining the polylineclosed - true if the polyline is closedp0 - point with respect to which distance should be determineddist - desired distance from p0r0 - for open polylines, a non-negative scalar giving the location
on the polyline where the search should start. This should be a
non-negative scalar whose value is less than or equal to the number of
polyline intervals, which will be vtxs.size()-1.reverse - if true and the polyline is open, search
backward from r0 instead of forwardpublic static double findPointAtDistance(Point3d pr, java.util.List<Point3d> vtxs, boolean closed, Point3d p0, double dist, double r0, boolean reverse)
public static double findPointAtDistance(java.util.List<Point3d> vtxs, boolean closed, double ra, double rb, Point3d p0, double dist, double tol)
dist from a prescribed point p0,
within a tolerance tol. The segment is defined by two point location
parameters ra and rb, which take the form described in
the documentation for getPointAt(double, java.util.List<maspack.matrix.Point3d>, boolean). Their values are restricted as
follows: rb should be an integer (and therefore corresponds to a
polyline vertex), while ra should correspond to a location
between this vertex and the vertex immediately preceeding or following
it.
If found, the method will return the point's location parameter r; otherwise, -1 will be returned.
vtxs - list of vertices defining the polylineclosed - true if the curve is closedra - location parameter giving the segment start pointrb - location parameter giving the segment end pointp0 - point with respect to which distance should be determineddist - desired distance from p0tol - tolerance for computing the pointpublic static double findNearestPoint(Point3d pr, java.util.List<Point3d> vtxs, boolean closed, Point3d p0, double r0)
p0. The polyline is specified by a list of vertices vtxs. Locations on the polyline are described by a non-negative
parameter r, which takes the form
r = k + swhere
k is the index of a polyline vertex, and s
is a scalar parameter in the range [0,1] that specifies the location
along the interval between vertices k and k+1. If the
polyline is open, the search for the nearest point begins at a location
specified by r0 and locations before r0 are ignored. If
the polyline is closed, r0 is ignored. The nearest point may not be
unique.
The method will return the nearest point's location parameter r, as well as the point's value in the optional parameter pr if
it is not null. If the polyline is empty, both r and
pr at set to 0.
It is assumed that no two adjacent vertices on the polyline are identical within machine precision. If they are, an exception will be thrown.
pr - if not null, returns the nearest pointvtxs - list of vertices defining the polylineclosed - true if the polyline is closedp0 - point for which the nearest point should be determinedr0 - for open polylines, a non-negative scalar giving the location
on the polyline where the search should start. This should be a
non-negative scalar whose value is less than or equal to the number of
polyline intervals, which will be vtxs.size()-1.public static Point3d getPointAt(double r, java.util.List<Point3d> vtxs, boolean closed)
vtxs, and the point location is
described by a non-negative location parameter r, which
takes the form
r = k + swhere
k is the index of a polyline vertex, and s is a
scalar parameter in the range [0,1] that specifies the location along the
interval between vertices k and k+1. If the polyline is
open, then r is clamped so as to not exceed numv-1,
where numv is the number of vertices. If the polyline is closed,
then r is reduced, using the modulo function, to the range
[0, numv).r - specifies the location on the polylinevtxs - list of vertices defining the polylineclosed - true if the polyline is closedjava.lang.IllegalArgumentException - if r is negative.