Package org.djutils.draw.curve
Class Bezier3d
java.lang.Object
org.djutils.draw.curve.Bezier3d
- All Implemented Interfaces:
Curve<DirectedPoint3d,
,Direction3d, Point3d, Flattener3d, PolyLine3d> Curve3d
,Flattener.FlattableCurve<Point3d,
Direction3d>
- Direct Known Subclasses:
BezierCubic3d
Continuous definition of a Bézier curve in 3d. This class is simply a helper class for (and a super of)
BezierCubic3d
, which uses this class to determine curvature, offset lines, etc.
Copyright (c) 2023-2025 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the derivative for a Bézier, which is a Bézier of 1 order lower.boolean
double
Return the length of this Curve.getPoint
(double t) Returns the point at the given fraction of this Curve.double
getX
(int i) Retrieve the x-coordinate of the i'th point of this Bézier curve.double
getY
(int i) Retrieve the y-coordinate of the i'th point of this Bézier curve.double
getZ
(int i) Retrieve the z-coordinate of the i'th point of this Bézier curve.int
hashCode()
double
length()
Returns the estimated path length of this Bézier curve using the method of numerical approach of Legendre-Gauss, which is quite accurate.int
size()
Return the number of points (or x-y pairs) that this Bézier curve is based on.toPolyLine
(Flattener3d flattener) Flatten a Curve into a PolyLine.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.djutils.draw.curve.Curve3d
getDirection, getEndDirection, getEndPoint, getStartDirection, getStartPoint
-
Constructor Details
-
Bezier3d
Create a Bézier curve of any order.- Parameters:
points
- Point2d... shape points that define the Bézier curve- Throws:
NullPointerException
- whenpoints
isnull
IllegalArgumentException
- whenpoints
has < 2 elements
-
Bezier3d
public Bezier3d(double[] x, double[] y, double[] z) Create a Bézier curve of any order.- Parameters:
x
- the x-coordinates of the points that define the Bézier curvey
- the y-coordinates of the points that define the Bézier curvez
- the z-coordinates of the points that define the Bézier curve- Throws:
NullPointerException
- whenx
,y
, orz
isnull
IllegalArgumentException
- when the length of thex
array is not equal to the length of they
array, or not equal to the length of thez
array, or less than2
-
-
Method Details
-
derivative
Returns the derivative for a Bézier, which is a Bézier of 1 order lower.- Returns:
- derivative Bézier
- Throws:
IllegalStateException
- when the order ofthis Bezier2d
is1
-
size
public int size()Return the number of points (or x-y pairs) that this Bézier curve is based on.- Returns:
- the number of points (or x-y pairs) that this Bézier curve is based on
-
length
public double length()Returns the estimated path length of this Bézier curve using the method of numerical approach of Legendre-Gauss, which is quite accurate.- Returns:
- estimated length.
-
getX
public double getX(int i) Retrieve the x-coordinate of the i'th point of this Bézier curve.- Parameters:
i
- the index- Returns:
- the x-coordinate of the i'th point of this Bézier curve
- Throws:
IndexOutOfBoundsException
- wheni < 0
, ori ≥ size()
-
getY
public double getY(int i) Retrieve the y-coordinate of the i'th point of this Bézier curve.- Parameters:
i
- the index- Returns:
- the y-coordinate of the i'th point of this Bézier curve
- Throws:
IndexOutOfBoundsException
- wheni < 0
, ori ≥ size()
-
getZ
public double getZ(int i) Retrieve the z-coordinate of the i'th point of this Bézier curve.- Parameters:
i
- the index- Returns:
- the z-coordinate of the i'th point of this Bézier curve
- Throws:
IndexOutOfBoundsException
- wheni < 0
, ori ≥ size()
-
getPoint
Description copied from interface:Curve
Returns the point at the given fraction of this Curve. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length.- Specified by:
getPoint
in interfaceCurve<DirectedPoint3d,
Direction3d, Point3d, Flattener3d, PolyLine3d> - Specified by:
getPoint
in interfaceFlattener.FlattableCurve<Point3d,
Direction3d> - Parameters:
t
- the fraction- Returns:
- the point at the given
fraction
-
getLength
public double getLength()Description copied from interface:Curve
Return the length of this Curve.- Specified by:
getLength
in interfaceCurve<DirectedPoint3d,
Direction3d, Point3d, Flattener3d, PolyLine3d> - Returns:
- length of this Curve
-
toPolyLine
Description copied from interface:Curve
Flatten a Curve into a PolyLine. Implementations should use the flattener when relevant and possible.- Specified by:
toPolyLine
in interfaceCurve<DirectedPoint3d,
Direction3d, Point3d, Flattener3d, PolyLine3d> - Parameters:
flattener
- the flattener- Returns:
- approximation of this
Curve
as aPolyLine
-
toString
-
hashCode
public int hashCode() -
equals
-