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

public class Bezier3d extends Object implements Curve3d
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
    Constructor
    Description
    Bezier3d(double[] x, double[] y, double[] z)
    Create a Bézier curve of any order.
    Bezier3d(Point3d... points)
    Create a Bézier curve of any order.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns 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
     
    double
    Returns the estimated path length of this Bézier curve using the method of numerical approach of Legendre-Gauss, which is quite accurate.
    int
    Return the number of points (or x-y pairs) that this Bézier curve is based on.
    Flatten a Curve into a PolyLine.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.djutils.draw.curve.Curve

    getKnots

    Methods inherited from interface org.djutils.draw.curve.Curve3d

    getDirection, getEndDirection, getEndPoint, getStartDirection, getStartPoint
  • Constructor Details

    • Bezier3d

      public Bezier3d(Point3d... points)
      Create a Bézier curve of any order.
      Parameters:
      points - Point2d... shape points that define the Bézier curve
      Throws:
      NullPointerException - when points is null
      IllegalArgumentException - when points 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 curve
      y - the y-coordinates of the points that define the Bézier curve
      z - the z-coordinates of the points that define the Bézier curve
      Throws:
      NullPointerException - when x, y, or z is null
      IllegalArgumentException - when the length of the x array is not equal to the length of the y array, or not equal to the length of the z array, or less than 2
  • Method Details

    • derivative

      public Bezier3d 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 of this Bezier2d is 1
    • 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 - when i < 0, or i ≥ 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 - when i < 0, or i ≥ 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 - when i < 0, or i ≥ size()
    • getPoint

      public Point3d getPoint(double t)
      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 interface Curve<DirectedPoint3d,Direction3d,Point3d,Flattener3d,PolyLine3d>
      Specified by:
      getPoint in interface Flattener.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 interface Curve<DirectedPoint3d,Direction3d,Point3d,Flattener3d,PolyLine3d>
      Returns:
      length of this Curve
    • toPolyLine

      public PolyLine3d toPolyLine(Flattener3d flattener)
      Description copied from interface: Curve
      Flatten a Curve into a PolyLine. Implementations should use the flattener when relevant and possible.
      Specified by:
      toPolyLine in interface Curve<DirectedPoint3d,Direction3d,Point3d,Flattener3d,PolyLine3d>
      Parameters:
      flattener - the flattener
      Returns:
      approximation of this Curve as a PolyLine
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object