Package org.djutils.draw.line
Class Ray3d
- java.lang.Object
-
- org.djutils.draw.point.Point3d
-
- org.djutils.draw.line.Ray3d
-
- All Implemented Interfaces:
Serializable
,Directed<Ray3d>
,Drawable<Point3d,Space3d>
,Drawable3d
,Ray<Ray3d,Point3d,Space3d>
,Point<Point3d,Space3d>
public class Ray3d extends Point3d implements Drawable3d, Ray<Ray3d,Point3d,Space3d>
Ray3d is a half-line; it has one end point with non-infinite coordinates; the other end point is infinitely far away.Copyright (c) 2020-2021 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
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Ray3d(double x, double y, double z, double phi, double theta)
Construct a new Ray3d.Ray3d(double x, double y, double z, double throughX, double throughY, double throughZ)
Construct a new Ray3d.Ray3d(double x, double y, double z, Point3d throughPoint)
Construct a new Ray3d.Ray3d(Point3d point, double phi, double theta)
Construct a new Ray3d.Ray3d(Point3d point, double throughX, double throughY, double throughZ)
Construct a new Ray3d.Ray3d(Point3d point, Point3d throughPoint)
Construct a new Ray3d.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Point3d
closestPointOnRay(Point3d point)
Project a Point on a Segment.boolean
epsilonEquals(Ray3d other, double epsilonCoordinate, double epsilonRotation)
Compare this Directed with another Directed with specified tolerances in the coordinates and the angles.boolean
equals(Object obj)
Bounds3d
getBounds()
Retrieve the bounding box of the object.Point3d
getEndPoint()
Get the finite end point of this Ray.Ray3d
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.double
getTheta()
Retrieve the angle from the positive Z axis direction in radians.int
hashCode()
Ray3d
neg()
Return a new Point with negated coordinate values.String
toString()
Return a string representation of the point.-
Methods inherited from class org.djutils.draw.point.Point3d
abs, closestPointOnLine, closestPointOnLine, closestPointOnSegment, distance, distanceSquared, epsilonEquals, getPoints, getX, getY, getZ, interpolate, normalize, project, scale, size, toString, translate, translate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.djutils.draw.Drawable3d
project
-
Methods inherited from interface org.djutils.draw.line.Ray
getLocation
-
-
-
-
Constructor Detail
-
Ray3d
public Ray3d(double x, double y, double z, double phi, double theta) throws DrawRuntimeException
Construct a new Ray3d.- Parameters:
x
- double; the x coordinate of the finite end point of the rayy
- double; the y coordinate of the finite end point of the rayz
- double; the z coordinate of the finite end point of the rayphi
- double; the angle from the positive X axis direction in radians.theta
- double; the angle from the positive Z axis direction in radians- Throws:
DrawRuntimeException
- when phi is NaN
-
Ray3d
public Ray3d(Point3d point, double phi, double theta) throws NullPointerException, DrawRuntimeException
Construct a new Ray3d.- Parameters:
point
- Point3d; the finite end point of the rayphi
- double; the angle from the positive X axis direction in radians.theta
- double; the angle from the positive Z axis direction in radians- Throws:
NullPointerException
- when point is nullDrawRuntimeException
- when phi is NaN, or theta is NaN
-
Ray3d
public Ray3d(double x, double y, double z, double throughX, double throughY, double throughZ) throws DrawRuntimeException
Construct a new Ray3d.- Parameters:
x
- double; the x coordinate of the finite end point of the rayy
- double; the y coordinate of the finite end point of the rayz
- double; the z coordinate of the finite end point of the raythroughX
- double; the x coordinate of another point on the raythroughY
- double; the y coordinate of another point on the raythroughZ
- double; the z coordinate of another point on the ray- Throws:
DrawRuntimeException
- when throughX == x and throughY == y
-
Ray3d
public Ray3d(Point3d point, double throughX, double throughY, double throughZ) throws NullPointerException, DrawRuntimeException
Construct a new Ray3d.- Parameters:
point
- Point3d; the finite end point of the raythroughX
- double; the x coordinate of another point on the raythroughY
- double; the y coordinate of another point on the raythroughZ
- double; the z coordinate of another point on the ray- Throws:
NullPointerException
- when point is nullDrawRuntimeException
- when throughX == point.x and throughY == point.y
-
Ray3d
public Ray3d(double x, double y, double z, Point3d throughPoint) throws NullPointerException, DrawRuntimeException
Construct a new Ray3d.- Parameters:
x
- double; the x coordinate of the finite end point of the rayy
- double; the y coordinate of the finite end point of the rayz
- double; the z coordinate of the finite end point of the raythroughPoint
- Point3d; another point on the ray- Throws:
NullPointerException
- when throughPoint is nullDrawRuntimeException
- when throughPoint is exactly at (x, y)
-
Ray3d
public Ray3d(Point3d point, Point3d throughPoint) throws NullPointerException, DrawRuntimeException
Construct a new Ray3d.- Parameters:
point
- Point3d; the finite end point of the raythroughPoint
- Point3d; another point on the ray- Throws:
NullPointerException
- when point is null or throughPoint is nullDrawRuntimeException
- when throughPoint is exactly at point
-
-
Method Detail
-
getPhi
public final double getPhi()
Retrieve the angle from the positive X axis direction in radians.
-
getTheta
public final double getTheta()
Retrieve the angle from the positive Z axis direction in radians.- Returns:
- double; the angle from the positive Z axis direction in radians
-
getEndPoint
public Point3d getEndPoint()
Get the finite end point of this Ray.- Specified by:
getEndPoint
in interfaceRay<Ray3d,Point3d,Space3d>
- Returns:
- P; the finite end point of this Ray
-
closestPointOnRay
public Point3d closestPointOnRay(Point3d point) throws NullPointerException
Project a Point on a Segment. 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.- Specified by:
closestPointOnRay
in interfaceRay<Ray3d,Point3d,Space3d>
- 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
-
neg
public Ray3d neg()
Return a new Point with negated coordinate values.
-
getLocationExtended
public Ray3d getLocationExtended(double position) throws DrawRuntimeException
Get the location at a position on the line, with its direction. Position must be a positive, finite value- Specified by:
getLocationExtended
in interfaceRay<Ray3d,Point3d,Space3d>
- 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.
-
getBounds
public Bounds3d getBounds()
Retrieve the bounding box of the object.- Specified by:
getBounds
in interfaceDrawable3d
- Overrides:
getBounds
in classPoint3d
- Returns:
- Bounds3d; the bounding box of the object
-
epsilonEquals
public boolean epsilonEquals(Ray3d other, double epsilonCoordinate, double epsilonRotation) throws NullPointerException, IllegalArgumentException
Compare this Directed with another Directed with specified tolerances in the coordinates and the angles.- Specified by:
epsilonEquals
in interfaceDirected<Ray3d>
- Parameters:
other
- D; the point to compare withepsilonCoordinate
- double; the upper bound of difference for one of the coordinates; use Double.POSITIVE_INFINITY if you do not want to check the coordinatesepsilonRotation
- double; the upper bound of difference for the direction(s); use Double.POSITIVE_INFINITY if you do not want to check the angles- Returns:
- boolean; true if x, y, and z are less than epsilonCoordinate apart, and rotX, rotY and rotZ are less than epsilonRotation apart, otherwise false
- Throws:
NullPointerException
- when point is nullIllegalArgumentException
- epsilonCoordinate or epsilonRotation is NaN or negative
-
-