Package org.djutils.draw.point
Class OrientedPoint3d
java.lang.Object
org.djutils.draw.point.Point3d
org.djutils.draw.point.DirectedPoint3d
org.djutils.draw.point.OrientedPoint3d
- All Implemented Interfaces:
Iterable<Point3d>,Directed,Directed3d,Drawable<Point3d>,Drawable3d,Oriented3d,Point<Point3d>
A OrientedPoint3d is a point with an x, y, and z coordinate, plus a 3d orientation. The orientation is specified by the
rotations around the x, y, and z-axis. A number of constructors and methods are provided for cases where only the rotation
around the z-axis is of importance. Orientation in 3D is stored as three double values dirX,dirY,dirZ. This class does
not prescribe a particular order in which these rotations are to be applied. (Applying rotations is not
commutative, so this is important.)
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
-
Field Summary
FieldsFields inherited from class org.djutils.draw.point.DirectedPoint3d
dirY, dirZ -
Constructor Summary
ConstructorsConstructorDescriptionOrientedPoint3d(double[] xyz) Create a new OrientedPoint3d with x, y, and z coordinates and direction 0,0,0.OrientedPoint3d(double[] xyz, double[] orientation) Create a new OrientedPoint3d with x, y, and z coordinates packed in a double array and orientation specified using a double array of three elements (containing dirX,dirY,dirZ in that order).OrientedPoint3d(double[] xyz, double dirX, double dirY, double dirZ) Create a new OrientedPoint3d with x, y, and z coordinates and orientation dirX,dirY,dirZ.OrientedPoint3d(double x, double y, double z) Create a new OrientedPoint3d with x, y, and z coordinates and direction 0,0,0.OrientedPoint3d(double x, double y, double z, double[] orientation) Create a new OrientedPoint3d with x, y, and z coordinates and orientation specified using a double array of three elements (containing dirX,dirY,dirZ in that order).OrientedPoint3d(double x, double y, double z, double dirX, double dirY, double dirZ) Create a new OrientedPoint3d with x, y, and z coordinates and orientation dirX,dirY,dirZ.OrientedPoint3d(Point3d point, double dirX, double dirY, double dirZ) Create a new OrientedPoint3d from another point and specified orientation dirX,dirY,dirZ. -
Method Summary
Modifier and TypeMethodDescriptionabs()Return a new Point with absolute coordinate values.booleanepsilonEquals(OrientedPoint3d other, double epsilonCoordinate, double epsilonRotation) Compare this Directed with another Directed with specified tolerances in the coordinates and the angles.booleandoublegetDirX()Return the rotation around the x-axis in radians.doublegetDirY()Retrieve the angle from the positive z axis to the direction.doublegetDirZ()Retrieve the angle from the positive x-axis.inthashCode()interpolate(OrientedPoint3d otherPoint, double fraction) Interpolate towards another OrientedPoint3d 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 OrientedPoint3d with an in-place rotation around the z-axis by the provided rotateZ.rotate(double rotateX, double rotateY, double rotateZ) Return a new OrientedPoint3d point with an in-place rotation by the provided rotateX, 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.DirectedPoint3d
epsilonEquals, interpolate, rotateMethods 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
-
dirX
public final double dirXThe direction as rotation around the x-axis.
-
-
Constructor Details
-
OrientedPoint3d
public OrientedPoint3d(double x, double y, double z) Create a new OrientedPoint3d with x, y, and z coordinates and direction 0,0,0.- Parameters:
x- the x coordinatey- the y coordinatez- the z coordinate- Throws:
IllegalArgumentException- whenx,y, orzisNaN
-
OrientedPoint3d
public OrientedPoint3d(double x, double y, double z, double dirX, double dirY, double dirZ) Create a new OrientedPoint3d with x, y, and z coordinates and orientation dirX,dirY,dirZ.- Parameters:
x- the x coordinatey- the y coordinatez- the z coordinatedirX- the direction as rotation around the x-axis with the point as the centerdirY- the direction as rotation around the y-axis with the point as the centerdirZ- the direction as rotation around the z-axis with the point as the center- Throws:
ArithmeticException- whenx,y,z,dirX,dirY, ordirZisNaN
-
OrientedPoint3d
public OrientedPoint3d(double[] xyz) Create a new OrientedPoint3d with x, y, and z coordinates and direction 0,0,0.- Parameters:
xyz- the x, y and z coordinates- Throws:
NullPointerException- whenxyzisnullIllegalArgumentException- when the length of thexyxarray is not 3IllegalArgumentException- when thexyxarray contains aNaNvalue
-
OrientedPoint3d
public OrientedPoint3d(double[] xyz, double dirX, double dirY, double dirZ) throws NullPointerException, IllegalArgumentException Create a new OrientedPoint3d with x, y, and z coordinates and orientation dirX,dirY,dirZ.- Parameters:
xyz- the x, y and z coordinatesdirX- the direction as rotation around the x-axis with the point as the centerdirY- the direction as rotation around the y-axis with the point as the centerdirZ- the direction as rotation around the z-axis with the point as the center- Throws:
NullPointerException- whenxyxisnullIllegalArgumentException- when the length of the xyz array is not 3ArithmeticException- whenxyzcontains aNaNvalue, ordirX,dirY, ordirZisNaN
-
OrientedPoint3d
Create a new OrientedPoint3d from another point and specified orientation dirX,dirY,dirZ.- Parameters:
point- the point from which this OrientedPoint3d will be instantiateddirX- the direction as rotation around the x-axis with the point as the centerdirY- the direction as rotation around the y-axis with the point as the centerdirZ- the direction as rotation around the z-axis with the point as the center- Throws:
NullPointerException- whenpointisnullArithmeticException- whendirX,dirY, ordirZisNaN
-
OrientedPoint3d
public OrientedPoint3d(double x, double y, double z, double[] orientation) Create a new OrientedPoint3d with x, y, and z coordinates and orientation specified using a double array of three elements (containing dirX,dirY,dirZ in that order).- Parameters:
x- the x coordinatey- the y coordinatez- the z coordinateorientation- the three orientation values as rotations around the x,y,z-axes in a double array containing dirX,dirY,dirZ in that order- Throws:
NullPointerException- whenrotationisnullIllegalArgumentException- when the length of thedirectionarray is not 3
-
OrientedPoint3d
public OrientedPoint3d(double[] xyz, double[] orientation) Create a new OrientedPoint3d with x, y, and z coordinates packed in a double array and orientation specified using a double array of three elements (containing dirX,dirY,dirZ in that order).- Parameters:
xyz- the x, y and z coordinates in that orderorientation- the three orientation values as rotations around the x,y,z-axes in a double array containing dirX,dirY,dirZ in that order- Throws:
NullPointerException- whenxyxordirectionisnullIllegalArgumentException- when the length of thexyxarray or the length of theorientationarray is not 3
-
-
Method Details
-
translate
Description copied from class:Point3dReturn a new Point3d with a translation by the provided dX and dY and preserved z value.- Overrides:
translatein classDirectedPoint3d- Parameters:
dX- the x translationdY- the y translation- Returns:
- a new point with the translated coordinates and the same
zvalue
-
translate
Description copied from class:Point3dReturn a new Point3d with a translation by the provided dx, dy and dz.- Overrides:
translatein classDirectedPoint3d- Parameters:
dX- the x translationdY- the y translationdZ- the z translation- Returns:
- a new point with the translated coordinates
-
scale
Description copied from interface:PointReturn a new Point with the coordinates of this point scaled by the provided factor.- Specified by:
scalein interfacePoint<Point3d>- Overrides:
scalein classDirectedPoint3d- Parameters:
factor- the scale factor- Returns:
- 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.- Specified by:
negin interfacePoint<Point3d>- Overrides:
negin classDirectedPoint3d- Returns:
- a new point with negated coordinate values
-
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.- Specified by:
absin interfacePoint<Point3d>- Overrides:
absin classDirectedPoint3d- Returns:
- a new point with absolute coordinate values
-
normalize
Description copied from interface:PointReturn a new Point with a distance of 1 to the origin.- Specified by:
normalizein interfacePoint<Point3d>- Overrides:
normalizein classDirectedPoint3d- Returns:
- the normalized point
- Throws:
IllegalArgumentException- when point is the origin, and no length can be established for scaling
-
interpolate
Interpolate towards another OrientedPoint3d 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. DirX, 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
OrientedPoint3dat the requestedfraction - Throws:
NullPointerException- whenotherPointisnullArithmeticException- whenfractionisNaN
-
rotate
Return a new OrientedPoint3d with an in-place rotation around the z-axis by the provided rotateZ. The resulting rotation will be normalized between -π and π.- Overrides:
rotatein classDirectedPoint3d- Parameters:
rotateZ- the rotation around the z-axis- Returns:
- a new point with the same coordinates,
dirXanddirYand modifieddirZ - Throws:
ArithmeticException- whenrotateZisNaN
-
rotate
Return a new OrientedPoint3d point with an in-place rotation by the provided rotateX, rotateY, and rotateZ. The resulting rotations will be normalized between -π and π.- Parameters:
rotateX- the rotation around the x-axisrotateY- 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- when any of the rotations isNaN
-
getDirX
public double getDirX()Description copied from interface:Oriented3dReturn the rotation around the x-axis in radians.- Specified by:
getDirXin interfaceOriented3d- Returns:
- the rotation around the x-axis in radians
-
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- Overrides:
getDirYin classDirectedPoint3d- Returns:
- dirY
-
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).- Specified by:
getDirZin interfaceDirected- Overrides:
getDirZin classDirectedPoint3d- Returns:
- the angle from the positive x-axis
-
iterator
- Specified by:
iteratorin interfaceIterable<Point3d>- Overrides:
iteratorin classDirectedPoint3d
-
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.- Specified by:
toStringin interfaceDrawable<Point3d>- Overrides:
toStringin classDirectedPoint3d- Returns:
- a string describing the Drawable
-
toString
Description copied from interface:DrawableProduce a String describing the Drawable.- Specified by:
toStringin interfaceDrawable<Point3d>- Overrides:
toStringin classDirectedPoint3d- 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(OrientedPoint3d other, double epsilonCoordinate, double epsilonRotation) 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 coordinatesepsilonRotation- the upper bound of difference for the rotation(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()- Overrides:
hashCodein classDirectedPoint3d
-
equals
- Overrides:
equalsin classDirectedPoint3d
-