Package org.djutils.draw.line
Interface Ray<R extends Ray<R,D,P>,D extends Directed<D>,P extends Point<P>>
- Type Parameters:
R
- The Ray type (2d or 3d)D
- The Directed type (2d or 3d)P
- The Point type (2d or 3d)
- All Superinterfaces:
Project<P>
public interface Ray<R extends Ray<R,D,P>,D extends Directed<D>,P extends Point<P>>
extends Project<P>
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-2025 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, Wouter Schakel
-
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).double
getDirZ()
Retrieve the angle from the positive X axis direction in radians.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.Methods inherited from interface org.djutils.draw.line.Project
projectOrthogonal, projectOrthogonalExtended, projectOrthogonalFractional, projectOrthogonalFractionalExtended
-
Method Details
-
getEndPoint
D getEndPoint()Get the finite end point of this Ray.- Returns:
- the finite end point of this Ray
-
getDirZ
double getDirZ()Retrieve the angle from the positive X axis direction in radians.- Returns:
- 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:
- Ray at the same location, but with
dirZ
(in case of a Ray3d) incremented by π anddirY
subtracted from π
-
getLocation
Get the location at a position on the line, with its direction. Position must be a positive, finite value- Parameters:
position
- the position on the line for which to calculate the point on the line- Returns:
- a ray with the same direction as this ray (even if the direction of this ray is not normalized)
- Throws:
ArithmeticException
- whenposition
isNaN
IllegalArgumentException
- whenposition
<0.0
, or infinite
-
getLocationExtended
Get the location at a position on the line, with its direction. Position must be a finite value- Parameters:
position
- the position on the line for which to calculate the point on the line- Returns:
- a ray with the same direction as this ray
- Throws:
ArithmeticException
- whenposition
isNaN
IllegalArgumentException
- whenposition
infinite
-
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 published by Paul Bourke.- Parameters:
point
- the point to project onto the segment- Returns:
- either the start point, or DirectedPoint that lies somewhere on this Ray
- Throws:
NullPointerException
- whenpoint
isnull
-