Package org.djutils.draw.point
Class DirectedPoint3d
java.lang.Object
org.djutils.draw.point.Point3d
org.djutils.draw.point.DirectedPoint3d
- All Implemented Interfaces:
Serializable
,Directed<DirectedPoint3d>
,Directed3d<DirectedPoint3d>
,Drawable<Point3d>
,Drawable3d
,Point<Point3d>
- Direct Known Subclasses:
OrientedPoint3d
,Ray3d
DirectedPoint3d.java.
Copyright (c) 2023-2024 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
- See Also:
-
Field Summary
Modifier 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
ConstructorDescriptionDirectedPoint3d
(double[] xyz, double[] orientation) 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 x, double y, double z, double[] orientation) Create a new DirectedPoint3d with x, y and z coordinates and orientation 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 orientation dirX,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, 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, 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.Iterator<? extends DirectedPoint3d>
Retrieve, or generate all points that make up the object.int
hashCode()
interpolate
(DirectedPoint3d otherPoint, double fraction) Interpolate towards another DirectedPoint3d with a fraction.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 OrientedPoint3d 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.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, 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.Drawable
getPointList, toString, toString
Methods inherited from interface org.djutils.draw.Drawable3d
getDimensions
-
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) throws IllegalArgumentException Create a new DirectedPoint3d with x, y, and z coordinates and orientation dirX,dirY,dirZ.- Parameters:
x
- double; the x coordinatey
- double; the y coordinatez
- double; the z coordinatedirY
- double; the complement of the slopedirZ
- double; the counter-clockwise rotation around the point in radians- Throws:
IllegalArgumentException
- when x, y, z, dirX, dirY, or dirZ is NaN
-
DirectedPoint3d
public DirectedPoint3d(double[] xyz, double dirY, double dirZ) throws NullPointerException, IllegalArgumentException Create a new DirectedPoint3d with x, y, and z coordinates in a double[] and direction dirY,dirZ.- Parameters:
xyz
- double[]; the x, y and z coordinatesdirY
- double; the complement of the slopedirZ
- double; the counter-clockwise rotation around the point in radians- Throws:
NullPointerException
- when xyx is nullIllegalArgumentException
- when the length of the xyz array is not 3, or contains a NaN value, or dirY, or dirZ is NaN
-
DirectedPoint3d
Create a new DirectedPoint3d from another Point3d and and direction dirY,dirZ.- Parameters:
point
- Point3d; the point from which this OrientedPoint3d will be instantiateddirY
- double; the complement of the slopedirZ
- double; the counter-clockwise rotation around the point in radians- Throws:
IllegalArgumentException
- when dirX, dirY, or dirZ is NaN
-
DirectedPoint3d
public DirectedPoint3d(double x, double y, double z, double throughX, double throughY, double throughZ) throws DrawRuntimeException Construct a new DirectedPoint3d from three coordinates and the coordinates of a point that the direction goes through.- Parameters:
x
- double; the x coordinate of the new DirectedPointy
- double; the y coordinate of the new DirectedPointz
- double; the z coordinate of the new DirectedPointthroughX
- double; the x-coordinate of a point that the direction goes throughthroughY
- double; the y-coordinate of a point that the direction goes throughthroughZ
- double; the z-coordinate of a point that the direction goes through- Throws:
DrawRuntimeException
- when throughX == x and throughY == y and throughZ == z, or any through-value is NaN
-
DirectedPoint3d
public DirectedPoint3d(Point3d point, double throughX, double throughY, double throughZ) throws DrawRuntimeException Construct a new DirectedPoint3d form a Point3d and the coordinates that the direction goes through.- Parameters:
point
- Point3d; the pointthroughX
- double; the x coordinate of a point that the direction goes throughthroughY
- double; the y coordinate of a point that the direction goes throughthroughZ
- double; the z coordinate of a point that the direction goes through- Throws:
DrawRuntimeException
- when throughX == point.x and throughY == point.y and throughZ == point.z, or any through-value is NaN
-
DirectedPoint3d
public DirectedPoint3d(double x, double y, double z, double[] orientation) throws NullPointerException, IllegalArgumentException Create a new DirectedPoint3d with x, y and z coordinates and orientation specified using a double array of two elements (containing dirY,dirZ in that order).- Parameters:
x
- double; the x coordinatey
- double; the y coordinatez
- double; the z coordinateorientation
- double[]; the two direction values (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
- whenorientation
is nullIllegalArgumentException
- when the length of thedirection
array is not 2, or contains a NaN value
-
DirectedPoint3d
public DirectedPoint3d(double[] xyz, double[] orientation) throws NullPointerException, IllegalArgumentException 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
- double[]; the x, y and z coordinates in that orderorientation
- double[]; the two orientation angles dirY and dirZ in that order- Throws:
NullPointerException
- when xyx or orientation is nullIllegalArgumentException
- when the length of the xyx array is not 3 or the length of the orientation array is not 2
-
DirectedPoint3d
public DirectedPoint3d(double x, double y, double z, Point3d throughPoint) throws NullPointerException, DrawRuntimeException Construct a new DirectedPoint3d from x, y and z coordinates and a point that the direction goes through.- Parameters:
x
- double; the x coordinate of the new DirectedPoint3dy
- double; the y coordinate of the new DirectedPoint3dz
- double; the z coordinate of the new DirectedPoint3dthroughPoint
- Point3d; a point that the direction goes through- Throws:
NullPointerException
- when throughPoint is nullDrawRuntimeException
- when throughPoint is exactly at (x, y, z)
-
DirectedPoint3d
public DirectedPoint3d(Point3d point, Point3d throughPoint) throws NullPointerException, DrawRuntimeException Construct a new DirectedPoint3d.- Parameters:
point
- Point3d; the location of the new DirectedPoint3dthroughPoint
- Point3d; another point that the direction goes through- Throws:
NullPointerException
- when point is null or throughPoint is nullDrawRuntimeException
- when throughPoint is exactly at point
-
-
Method Details
-
translate
Description copied from class:Point3d
Return a new Point3d with a translation by the provided dx and dy.- Overrides:
translate
in classPoint3d
- Parameters:
dx
- double; the x translationdy
- double; the y translation- Returns:
- Point3D; a new point with the translated coordinates
- Throws:
IllegalArgumentException
- when dx, or dy is NaN
-
translate
Description copied from class:Point3d
Return a new Point3d with a translation by the provided dx, dy and dz.- Overrides:
translate
in classPoint3d
- Parameters:
dx
- double; the x translationdy
- double; the y translationdz
- double; the z translation- Returns:
- Point3d; a new point with the translated coordinates
- Throws:
IllegalArgumentException
- when dx, dy, or dz is NaN
-
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 a DirectedPoint, dirY and dirZ are negated. -
abs
Description copied from interface:Point
Return a new Point with absolute coordinate values. If this is a DirectedPoint, dirY and dirZ are copied unchanged. -
normalize
Description copied from interface:Point
Return a new Point with a distance of 1 to the origin. -
interpolate
public DirectedPoint3d interpolate(DirectedPoint3d otherPoint, double fraction) throws NullPointerException, IllegalArgumentException 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
- OrientedPoint3d; the other pointfraction
- double; 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:
- DirectedPoint3d; a new OrientedPoint3d at the requested fraction
- Throws:
NullPointerException
- when otherPoint is nullIllegalArgumentException
- when fraction is NaN
-
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
- double; the rotation around the z-axis- Returns:
- DirectedPoint3d; a new point with the same coordinates, dirX and dirY and modified dirZ
- Throws:
IllegalArgumentException
- when rotateZ is NaN
-
rotate
Return a new OrientedPoint3d point with an in-place rotation by the provided rotateY, and rotateZ. The resulting rotations will be normalized between -π and π.- Parameters:
rotateY
- double; the rotation around the y-axisrotateZ
- double; the rotation around the z-axis- Returns:
- DirectedPoint3d; a new point with the same coordinates and applied rotations
- Throws:
IllegalArgumentException
- when any of the rotations is NaN
-
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:
- double; 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 less than π/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:
- double; dirY
-
getPoints
Description copied from interface:Drawable
Retrieve, or generate all points that make up the object. -
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
- String; a format string (something like "%6.3f") which will be used to render every coordinate value)doNotIncludeClassName
- boolean; if true; the output of toString 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:
- String; 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
- D; the Directed to compare toepsilonCoordinate
- 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
-
hashCode
public int hashCode() -
equals
-