Package org.djutils.draw.point
Class DirectedPoint3d
java.lang.Object
org.djutils.draw.point.Point3d
org.djutils.draw.point.DirectedPoint3d
- All Implemented Interfaces:
Serializable
,Iterable<Point3d>
,Directed<DirectedPoint3d>
,Directed3d<DirectedPoint3d>
,Drawable<Point3d>
,Drawable3d
,Point<Point3d>
- Direct Known Subclasses:
OrientedPoint3d
,Ray3d
A DirectedPoint3d is a point in 3d space that additionally carries a direction in 3d i.c. dirY (similar to tilt; measured as
an angle from the positive z-direction) and dirZ (similar to pan; measured as an angle from the positive x-direction).
Copyright (c) 2023-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal double
The direction as rotation around the x-axis.final double
The direction as rotation from the positive z-axis towards the x-y plane. -
Constructor Summary
ConstructorsConstructorDescriptionDirectedPoint3d
(double[] xyz, double[] directionVector) Create a new OrientedPoint3d from x, y and z coordinates packed in a double array of three elements and a direction specified using a double array of two elements.DirectedPoint3d
(double[] xyz, double dirY, double dirZ) Create a new DirectedPoint3d with x, y, and z coordinates in a double[] and direction dirY,dirZ.DirectedPoint3d
(double[] xyz, Direction3d dir) Create a new DirectedPoint3d with x, y, and z coordinates in a double[] and a Direction3d.DirectedPoint3d
(double x, double y, double z, double[] directionVector) Create a new DirectedPoint3d with x, y and z coordinates and direction specified using a double array of two elements (containing dirY,dirZ in that order).DirectedPoint3d
(double x, double y, double z, double dirY, double dirZ) Create a new DirectedPoint3d with x, y, and z coordinates and direction dirY,dirZ.DirectedPoint3d
(double x, double y, double z, double throughX, double throughY, double throughZ) Construct a new DirectedPoint3d from three coordinates and the coordinates of a point that the direction goes through.DirectedPoint3d
(double x, double y, double z, Direction3d dir) Create a new DirectedPoint3d with x, y, and z coordinates and Direction3d.DirectedPoint3d
(double x, double y, double z, Point3d throughPoint) Construct a new DirectedPoint3d from x, y and z coordinates and a point that the direction goes through.DirectedPoint3d
(Point3d point, double dirY, double dirZ) Create a new DirectedPoint3d from another Point3d and and direction dirY,dirZ.DirectedPoint3d
(Point3d point, double throughX, double throughY, double throughZ) Construct a new DirectedPoint3d form a Point3d and the coordinates that the direction goes through.DirectedPoint3d
(Point3d point, Direction3d direction) Create a new DirectedPoint3d from another Point3d and a Direction3d.DirectedPoint3d
(Point3d point, Point3d throughPoint) Construct a new DirectedPoint3d. -
Method Summary
Modifier and TypeMethodDescriptionabs()
Return a new Point with absolute coordinate values.boolean
epsilonEquals
(DirectedPoint3d other, double epsilonCoordinate, double epsilonRotation) Compare this Directed with another Directed with specified tolerances in the coordinates and the angles.boolean
double
getDirY()
Retrieve the angle from the positive z axis to the direction.double
getDirZ()
Retrieve the angle from the positive x-axis to the projection of the direction in the x-y-plane.int
hashCode()
interpolate
(DirectedPoint3d otherPoint, double fraction) Interpolate towards another DirectedPoint3d with a fraction.iterator()
neg()
Return a new Point with negated coordinate values.Return a new Point with a distance of 1 to the origin.rotate
(double rotateZ) Return a new DirectedPoint3d with an in-place rotation around the z-axis by the provided rotateZ.rotate
(double rotateY, double rotateZ) Return a new DirectedPoint3d point with an in-place rotation by the provided rotateY, and rotateZ.scale
(double factor) Return a new Point with the coordinates of this point scaled by the provided factor.toString()
Produce a string describing the Drawable using default conversion for the (double) coordinate values.Produce a String describing the Drawable.translate
(double dX, double dY) Return a new Point3d with a translation by the provided dX and dY and preserved z value.translate
(double dX, double dY, double dZ) Return a new Point3d with a translation by the provided dx, dy and dz.Methods inherited from class org.djutils.draw.point.Point3d
closestPointOnLine, closestPointOnLine, closestPointOnLine, closestPointOnSegment, closestPointOnSegment, directionTo, distance, distanceSquared, epsilonEquals, fractionalPositionOnLine, getBounds, getX, getY, getZ, horizontalDirection, horizontalDirection, horizontalDistance, horizontalDistanceSquared, interpolate, project, size, verticalDirection
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.djutils.draw.Directed3d
getDir
Methods inherited from interface org.djutils.draw.Drawable
getPointList, toString, toString
Methods inherited from interface org.djutils.draw.Drawable3d
getDimensions
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
dirY
public final double dirYThe direction as rotation around the x-axis. -
dirZ
public final double dirZThe direction as rotation from the positive z-axis towards the x-y plane.
-
-
Constructor Details
-
DirectedPoint3d
public DirectedPoint3d(double x, double y, double z, double dirY, double dirZ) Create a new DirectedPoint3d with x, y, and z coordinates and direction dirY,dirZ.- Parameters:
x
- the x coordinatey
- the y coordinatez
- the z coordinatedirY
- the complement of the slopedirZ
- the counter-clockwise rotation around the point in radians- Throws:
ArithmeticException
- whenx
,y
,z
,dirY
, ordirZ
isNaN
-
DirectedPoint3d
public DirectedPoint3d(double x, double y, double z, double[] directionVector) Create a new DirectedPoint3d with x, y and z coordinates and direction specified using a double array of two elements (containing dirY,dirZ in that order).- Parameters:
x
- the x coordinatey
- the y coordinatez
- the z coordinatedirectionVector
- the two direction angles (dirY and dirZ) in a double array containing dirY and dirZ in that order. DirY is the rotation from the positive z-axis to the direction. DirZ is the angle from the positive x-axis to the projection of the direction in the x-y-plane.- Throws:
NullPointerException
- whendirectionVector
isnull
ArithmeticException
- whenx
,y
,z
isNaN
, ordirectionVector
contains aNaN
valueIllegalArgumentException
- when the length of thedirectionVector
array is not 2, or contains aNaN
value
-
DirectedPoint3d
Create a new DirectedPoint3d with x, y, and z coordinates and Direction3d.- Parameters:
x
- the x coordinatey
- the y coordinatez
- the z coordinatedir
- the direction- Throws:
NullPointerException
- whendir>
isnull
ArithmeticException
- whenx
,y
,z
,dirY
, ordirZ
isNaN
-
DirectedPoint3d
public DirectedPoint3d(double x, double y, double z, double throughX, double throughY, double throughZ) Construct a new DirectedPoint3d from three coordinates and the coordinates of a point that the direction goes through.- Parameters:
x
- the x coordinate of the new DirectedPointy
- the y coordinate of the new DirectedPointz
- the z coordinate of the new DirectedPointthroughX
- the x-coordinate of a point that the direction goes throughthroughY
- the y-coordinate of a point that the direction goes throughthroughZ
- the z-coordinate of a point that the direction goes through- Throws:
ArithmeticException
- whenz
,y
,z
,throughX
,throughY
, orthroughZ
isNaN
IllegalArgumentException
- whenthroughX
==x
andthroughY
==y
andthroughZ
==z
-
DirectedPoint3d
Construct a new DirectedPoint3d from x, y and z coordinates and a point that the direction goes through.- Parameters:
x
- the x coordinate of the new DirectedPoint3dy
- the y coordinate of the new DirectedPoint3dz
- the z coordinate of the new DirectedPoint3dthroughPoint
- a point that the direction goes through- Throws:
NullPointerException
- whenthroughPoint
isnull
ArithmeticException
- whenx
,y
, orz
isNaN
IllegalArgumentException
- whenthroughPoint
is exactly at(x y,z)
-
DirectedPoint3d
public DirectedPoint3d(double[] xyz, double dirY, double dirZ) Create a new DirectedPoint3d with x, y, and z coordinates in a double[] and direction dirY,dirZ.- Parameters:
xyz
- the x, y and z coordinatesdirY
- the complement of the slopedirZ
- the counter-clockwise rotation around the point in radians- Throws:
NullPointerException
- whenxyx
isnull
IllegalArgumentException
- when the length of thexyz
array is not 3, or contains aNaN
value, ordirY
, ordirZ
isNaN
-
DirectedPoint3d
public DirectedPoint3d(double[] xyz, double[] directionVector) Create a new OrientedPoint3d from x, y and z coordinates packed in a double array of three elements and a direction specified using a double array of two elements.- Parameters:
xyz
- thex
,y
andz
coordinates in that orderdirectionVector
- the two direction anglesdirY
anddirZ
in that order- Throws:
NullPointerException
- whenxyz
, ordirectionVector
isnull
ArithmeticException
- whenxyz
, ordirectionVector
contains aNaN
valueIllegalArgumentException
- when the length of thexyx
is not 3 or the length of thedirectionVector
is not 2
-
DirectedPoint3d
Create a new DirectedPoint3d with x, y, and z coordinates in a double[] and a Direction3d.- Parameters:
xyz
- the x, y and z coordinatesdir
- the direction- Throws:
NullPointerException
- whenxyx
isnull
, ordir
isnull
IllegalArgumentException
- when the length of thexyz
array is not 3, or contains aNaN
value
-
DirectedPoint3d
Create a new DirectedPoint3d from another Point3d and and direction dirY,dirZ.- Parameters:
point
- the point from which this OrientedPoint3d will be instantiateddirY
- the complement of the slopedirZ
- the counter-clockwise rotation around the point in radians- Throws:
ArithmeticException
- whendirY
, ordirZ
isNaN
-
DirectedPoint3d
Create a new DirectedPoint3d from another Point3d and a Direction3d.- Parameters:
point
- the point from which this OrientedPoint3d will be instantiateddirection
- the direction- Throws:
NullPointerException
- whenpoint
, ordirection
isnull
-
DirectedPoint3d
Construct a new DirectedPoint3d form a Point3d and the coordinates that the direction goes through.- Parameters:
point
- the pointthroughX
- the x coordinate of a point that the direction goes throughthroughY
- the y coordinate of a point that the direction goes throughthroughZ
- the z coordinate of a point that the direction goes through- Throws:
NullPointerException
- whenpoint
isnull
ArithmeticException
- whenthroughX
, orthroughY
, orthroughZ
isNaN
IllegalArgumentException
- whenthroughX
==point.x
andthroughY
==point.y
andthroughZ
==point.z
-
DirectedPoint3d
Construct a new DirectedPoint3d.- Parameters:
point
- the location of the new DirectedPoint3dthroughPoint
- another point that the direction goes through- Throws:
NullPointerException
- whenpoint
isnull
orthroughPoint
isnull
IllegalArgumentException
- whenthroughPoint
is exactly atpoint
-
-
Method Details
-
translate
Description copied from class:Point3d
Return a new Point3d with a translation by the provided dX and dY and preserved z value. -
translate
Description copied from class:Point3d
Return a new Point3d with a translation by the provided dx, dy and dz. -
scale
Description copied from interface:Point
Return a new Point with the coordinates of this point scaled by the provided factor. -
neg
Description copied from interface:Point
Return a new Point with negated coordinate values. If this is aDirectedPoint
,dirY
(in case this is aDirectedPoint3d
anddirZ
are negated. -
abs
Description copied from interface:Point
Return a new Point with absolute coordinate values. If this is aDirectedPoint
,dirY
(in case this is aDirectedPoint3d
anddirZ
are copied unchanged. -
normalize
Description copied from interface:Point
Return a new Point with a distance of 1 to the origin. -
interpolate
Interpolate towards another DirectedPoint3d with a fraction. It is allowed for fraction to be less than zero or larger than 1. In that case the interpolation turns into an extrapolation. DirY and dirZ are interpolated/extrapolated using the interpolateShortest method.- Parameters:
otherPoint
- the other pointfraction
- the factor for interpolation towards the other point. When <code>fraction</code> is between 0 and 1, it is an interpolation, otherwise an extrapolation. Iffraction
is 0;this
Point is returned; iffraction
is 1, theotherPoint
is returned- Returns:
- a new
DirectedPoint3d
at the requestedfraction
- Throws:
NullPointerException
- whenotherPoint
isnull
ArithmeticException
- whenfraction
isNaN
-
rotate
Return a new DirectedPoint3d with an in-place rotation around the z-axis by the provided rotateZ. The resulting rotation will be normalized between -π and π.- Parameters:
rotateZ
- the rotation around the z-axis- Returns:
- a new point with the same coordinates,
dirY
and modifieddirZ
- Throws:
ArithmeticException
- whenrotateZ
isNaN
-
rotate
Return a new DirectedPoint3d point with an in-place rotation by the provided rotateY, and rotateZ. The resulting rotations will be normalized between -π and π.- Parameters:
rotateY
- the rotation around the y-axisrotateZ
- the rotation around the z-axis- Returns:
- a new point with the same coordinates and applied rotations
- Throws:
ArithmeticException
- whenrotateY
, orrotateZ
isNaN
-
getDirZ
public double getDirZ()Description copied from interface:Directed3d
Retrieve the angle from the positive x-axis to the projection of the direction in the x-y-plane. Positive values rotate towards the positive y-axis (and beyond).- Specified by:
getDirZ
in interfaceDirected3d<DirectedPoint3d>
- Returns:
- dirZ
-
getDirY
public double getDirY()Description copied from interface:Directed3d
Retrieve the angle from the positive z axis to the direction. Normally these are values between [0:π]. Angles ≤ π/2 indicate above the x-y-plane; positive slope, angles > π/2 indicate angles below this plane; negative slope.- Specified by:
getDirY
in interfaceDirected3d<DirectedPoint3d>
- Returns:
- dirY
-
iterator
-
toString
Description copied from interface:Drawable
Produce a string describing the Drawable using default conversion for the (double) coordinate values. Regrettably, it is not allowed to provide a default implementation here. -
toString
Description copied from interface:Drawable
Produce a String describing the Drawable.- Specified by:
toString
in interfaceDrawable<Point3d>
- Overrides:
toString
in classPoint3d
- Parameters:
doubleFormat
- a format string (something like "%6.3f") which will be used to render every coordinate value)doNotIncludeClassName
- iftrue
; the output oftoString
is not prefixed by the class name. This is useful for concatenating the textual representation of lots of Drawables (e.g. an array, or a List).- Returns:
- textual representation of the Drawable
-
epsilonEquals
public boolean epsilonEquals(DirectedPoint3d other, double epsilonCoordinate, double epsilonRotation) throws NullPointerException, IllegalArgumentException Description copied from interface:Directed
Compare this Directed with another Directed with specified tolerances in the coordinates and the angles.- Specified by:
epsilonEquals
in interfaceDirected<DirectedPoint3d>
- Parameters:
other
- the Directed to compare toepsilonCoordinate
- the upper bound of difference for one of the coordinates; use Double.POSITIVE_INFINITY if you do not want to check the coordinatesepsilonRotation
- 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
ifx
,y
, andz
are less thanepsilonCoordinate
apart, androtX
,rotY
androtZ
are less thanepsilonRotation
apart, otherwisefalse
- Throws:
NullPointerException
- whenother
isnull
IllegalArgumentException
-epsilonCoordinate
orepsilonRotation
isnegative
-
hashCode
public int hashCode() -
equals
-