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,Directed3d,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 doubleThe direction as rotation around the x-axis.final doubleThe 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.booleanepsilonEquals(DirectedPoint3d other, double epsilonCoordinate, double epsilonDirection) Compare this Directed with another Directed with specified tolerances in the coordinates and the angles.booleandoublegetDirY()Retrieve the angle from the positive z axis to the direction.doublegetDirZ()Retrieve the angle from the positive x-axis.inthashCode()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, getAbsoluteBounds, getX, getY, getZ, horizontalDirection, horizontalDirection, horizontalDistance, horizontalDistanceSquared, interpolate, project, size, verticalDirectionMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.draw.Directed3d
getDirMethods inherited from interface org.djutils.draw.Drawable
getPointList, toString, toStringMethods inherited from interface org.djutils.draw.Drawable3d
getDimensionsMethods 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, ordirZisNaN
-
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- whendirectionVectorisnullArithmeticException- whenx,y,zisNaN, ordirectionVectorcontains aNaNvalueIllegalArgumentException- when the length of thedirectionVectorarray is not 2, or contains aNaNvalue
-
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>isnullArithmeticException- whenx,y,z,dirY, ordirZisNaN
-
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, orthroughZisNaNIllegalArgumentException- whenthroughX==xandthroughY==yandthroughZ==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- whenthroughPointisnullArithmeticException- whenx,y, orzisNaNIllegalArgumentException- whenthroughPointis 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- whenxyxisnullIllegalArgumentException- when the length of thexyzarray is not 3, or contains aNaNvalue, ordirY, ordirZisNaN
-
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,yandzcoordinates in that orderdirectionVector- the two direction anglesdirYanddirZin that order- Throws:
NullPointerException- whenxyz, ordirectionVectorisnullArithmeticException- whenxyz, ordirectionVectorcontains aNaNvalueIllegalArgumentException- when the length of thexyxis not 3 or the length of thedirectionVectoris 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- whenxyxisnull, ordirisnullIllegalArgumentException- when the length of thexyzarray is not 3, or contains aNaNvalue
-
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, ordirZisNaN
-
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, ordirectionisnull
-
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- whenpointisnullArithmeticException- whenthroughX, orthroughY, orthroughZisNaNIllegalArgumentException- whenthroughX==point.xandthroughY==point.yandthroughZ==point.z
-
DirectedPoint3d
Construct a new DirectedPoint3d.- Parameters:
point- the location of the new DirectedPoint3dthroughPoint- another point that the direction goes through- Throws:
NullPointerException- whenpointisnullorthroughPointisnullIllegalArgumentException- whenthroughPointis exactly atpoint
-
-
Method Details
-
translate
Description copied from class:Point3dReturn a new Point3d with a translation by the provided dX and dY and preserved z value. -
translate
Description copied from class:Point3dReturn a new Point3d with a translation by the provided dx, dy and dz. -
scale
Description copied from interface:PointReturn a new Point with the coordinates of this point scaled by the provided factor. -
neg
Description copied from interface:PointReturn a new Point with negated coordinate values. If this is aDirectedPoint,dirY(in case this is aDirectedPoint3danddirZare negated. -
abs
Description copied from interface:PointReturn a new Point with absolute coordinate values. If this is aDirectedPoint,dirY(in case this is aDirectedPoint3danddirZare copied unchanged. -
normalize
Description copied from interface:PointReturn 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. Iffractionis 0;thisPoint is returned; iffractionis 1, theotherPointis returned- Returns:
- a new
DirectedPoint3dat the requestedfraction - Throws:
NullPointerException- whenotherPointisnullArithmeticException- whenfractionisNaN
-
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,
dirYand modifieddirZ - Throws:
ArithmeticException- whenrotateZisNaN
-
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, orrotateZisNaN
-
getDirZ
public double getDirZ()Description copied from interface:DirectedRetrieve the angle from the positive x-axis. Positive rotates towards the positive y-axis (and beyond). -
getDirY
public double getDirY()Description copied from interface:Directed3dRetrieve 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:
getDirYin interfaceDirected3d- Returns:
- dirY
-
iterator
-
toString
Description copied from interface:DrawableProduce 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:DrawableProduce a String describing the Drawable.- Specified by:
toStringin interfaceDrawable<Point3d>- Overrides:
toStringin classPoint3d- Parameters:
doubleFormat- a format string (something like "%6.3f") which will be used to render every coordinate value)doNotIncludeClassName- iftrue; the output oftoStringis 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 epsilonDirection) throws NullPointerException, IllegalArgumentException Compare this Directed with another Directed with specified tolerances in the coordinates and the angles.- 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 coordinatesepsilonDirection- the upper bound of difference for the direction(s); use Double.POSITIVE_INFINITY if you do not want to check the angles- Returns:
- boolean;
trueifx,y, and possiblyzare less thanepsilonCoordinateapart, androtZand possiblyrotX, and possiblyrotYare less thanepsilonDirectionapart, otherwisefalse - Throws:
NullPointerException- whenotherisnullArithmeticException- whenepsilonCoordinateorepsilonDirectionisNaNIllegalArgumentException-epsilonCoordinateorepsilonDirectionisnegative
-
hashCode
public int hashCode() -
equals
-