/** * Tests whether the projection of the given point onto this line segment is located * between the two endpoints with a given conservative tolerance {@code epsilon}: * <ul> * <li> if {@code epsilon > 0}, the point has to be between the endpoints and at a minimum * distance of {@code epsilon * this.length()} from the closest endpoint. * <li> if {@code epsilon < 0}, the point has to be between the endpoints or at a maximum * distance of {@code -epsilon * this.length()} from the closest endpoint. * <li> if {@code epsilon = 0}, the point has to be between the endpoints or equal to * one of the endpoints. * </ul> * * @param x the x-coordinate of the query point. * @param y the y-coordinate of the query point. * @param z the z-coordinate of the query point. * @param epsilon the tolerance to use. * @return {@code true} if the projection of the point is between the endpoints of this line segment, {@code false} otherwise. */ public boolean isBetweenEndpoints(double x, double y, double z, double epsilon) { double alpha = percentageAlongLineSegment(x, y, z); if (alpha < epsilon) return false; if (alpha > 1.0 - epsilon) return false; return true; }

/** * Computes a percentage along the line segment representing the location of the given point once projected onto this line segment. * The returned percentage is in ] -∞; ∞ [, {@code 0.0} representing {@code firstEndpoint}, and {@code 1.0} representing {@code secondEndpoint}. * <p> * For example, if the returned percentage is {@code 0.5}, it means that the projection of the given point is located at the middle of this line segment. * The coordinates of the projection of the point can be computed from the {@code percentage} as follows: * <code> * Point3d projection = new Point3d(); </br> * projection.interpolate(lineSegmentStart, lineSegmentEnd, percentage); </br> * </code> * </p> * <p> * Edge cases: * <ul> * <li> if the length of the given line segment is too small, i.e. {@code this.length() < Epsilons.ONE_TRILLIONTH}, this method fails and returns {@code 0.0}. * </ul> * </p> * * @param point the query point. Not modified. * @return the computed percentage along the line segment representing where the point projection is located. */ public double percentageAlongLineSegment(Point3d point) { return percentageAlongLineSegment(point.getX(), point.getY(), point.getZ()); }

## Javadoc

Computes a percentage along the line segment representing the location of the given point once projected onto this line segment.
The returned percentage is in ] -∞; ∞ [,
0.0 representing
firstEndpoint, and
1.0 representing
secondEndpoint.

For example, if the returned percentage is
0.5, it means that the projection of the given point is located at the middle of this line segment.
The coordinates of the projection of the point can be computed from the
percentage as follows:
```
Point3d projection = new Point3d();
```

projection.interpolate(lineSegmentStart, lineSegmentEnd, percentage);

Edge cases:

- if the length of the given line segment is too small, i.e. this.length() < Epsilons.ONE_TRILLIONTH, this method fails and returns 0.0.

## Popular methods of LineSegment3d

- getFirstEndpoint
- getSecondEndpoint
- <init>Initializes this line segment to have the given endpoints.
- distanceThis methods computes the minimum distance between this line segment and the given one. Useful link
- firstEndpointContainsNaNTest if the first endpoint of this line segment contains Double#NaN.
- getDirectionComputes the vector going from the first to the second endpoint of this line segment.
- getDirectionCopyComputes the vector going from the first to the second endpoint of this line segment. WARNING: This
- getMidpointComputes the coordinates of the point located exactly at the middle of this line segment.
- isBetweenEndpointsTests whether the projection of the given point onto this line segment is located between the two en
- lengthComputes the length of this line segment.
- orthogonalProjectionComputes the orthogonal projection of a 3D point on this 3D line segment. Edge cases: * if the leng
- pointBetweenEndPointsGivenPercentageComputes the coordinates of the point located at a given percentage on this line segment: pointToPac

## Popular in Java

- Finding current android device location
- setContentView (Activity)
- getApplicationContext (Context)
- getOriginalFilename (MultipartFile)Return the original filename in the client's filesystem.This may contain path information depending
- URLEncoder (java.net)This class is used to encode a string using the format required by application/x-www-form-urlencoded
- HashMap (java.util)HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
- BlockingQueue (java.util.concurrent)A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
- ThreadPoolExecutor (java.util.concurrent)An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
- Options (org.apache.commons.cli)Main entry-point into the library. Options represents a collection of Option objects, which describ
- Color (java.awt)The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
- Top PhpStorm plugins