Package org.djutils.draw.line
Interface Ray<R extends Ray<R,P>,P extends Point<P>>
- Type Parameters:
R
- The Ray type (2d or 3d)P
- The Point type (2d, or 3d)
A Ray is a half-line; it has one end point with non-infinite coordinates; the other end point is infinitely far away.
Copyright (c) 2020-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUTILS License.
- Author:
- Alexander Verbraeck, Peter Knoppers
-
Method Summary
Modifier and TypeMethodDescriptionclosestPointOnRay
(P point) Project a Point on a Ray.flip()
Flip the direction of the Ray (creates and returns a new Ray instance).Get the finite end point of this Ray.default R
getLocation
(double position) Get the location at a position on the line, with its direction.getLocationExtended
(double position) Get the location at a position on the line, with its direction.double
getPhi()
Retrieve the angle from the positive X axis direction in radians.Methods inherited from interface org.djutils.draw.Directed
epsilonEquals, neg
Methods inherited from interface org.djutils.draw.line.Project
projectOrthogonal, projectOrthogonalExtended, projectOrthogonalFractional, projectOrthogonalFractionalExtended
-
Method Details
-
getEndPoint
P getEndPoint()Get the finite end point of this Ray.- Returns:
- P; the finite end point of this Ray
-
getPhi
double getPhi()Retrieve the angle from the positive X axis direction in radians.- Returns:
- double; the angle from the positive X axis direction in radians
-
flip
R flip()Flip the direction of the Ray (creates and returns a new Ray instance).- Returns:
- R; Ray at the same location, but with phi incremented by π and theta (in case of a Ray3d) subtracted from π
-
getLocation
Get the location at a position on the line, with its direction. Position must be a positive, finite value- Parameters:
position
- double; the position on the line for which to calculate the point on the line- Returns:
- R; a ray with the same direction as this ray (even if the direction of this ray is not normalized)
- Throws:
DrawRuntimeException
- when position less than 0.0, infinite, or NaN.
-
getLocationExtended
Get the location at a position on the line, with its direction. Position must be a positive, finite value- Parameters:
position
- double; the position on the line for which to calculate the point on the line- Returns:
- R; a ray with the same direction as this ray
- Throws:
DrawRuntimeException
- when position infinite, or NaN.
-
closestPointOnRay
Project a Point on a Ray. If the the projected points lies outside the ray, the start point of the ray is returned. Otherwise the closest point on the ray is returned.
Adapted from example code provided by Paul Bourke.- Parameters:
point
- P; the point to project onto the segment- Returns:
- P; either the start point, or the end point of the segment or a Point2d that lies somewhere in between those two.
- Throws:
NullPointerException
- when point is null
-