Class Bezier

java.lang.Object
org.djutils.draw.curve.Bezier

public final class Bezier extends Object
Common code used to generated Bézier curves.

Copyright (c) 2013-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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final double[]
    C values of numerical approach of Legendre-Gauss to determine Bézier length.
    static final int
    The default number of points to use to construct a Bézier curve.
    (package private) static final double[]
    T values of numerical approach of Legendre-Gauss to determine Bézier length.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static double
    Bn(double t, double... p)
    Calculate the Bézier point of degree n, with B(t) = Σ(i = 0..n) [C(n, i) * (1 - t)n-i ti Pi], where C(n, k) is the binomial coefficient defined by n!
    static double[]
    derivative(double[] in)
    Returns the derivative for one dimension of a Bézier, which is a Bézier of 1 order lower.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • T

      static final double[] T
      T values of numerical approach of Legendre-Gauss to determine Bézier length.
    • C

      static final double[] C
      C values of numerical approach of Legendre-Gauss to determine Bézier length.
    • DEFAULT_BEZIER_SIZE

      public static final int DEFAULT_BEZIER_SIZE
      The default number of points to use to construct a Bézier curve.
      See Also:
  • Method Details

    • Bn

      static double Bn(double t, double... p)
      Calculate the Bézier point of degree n, with B(t) = Σ(i = 0..n) [C(n, i) * (1 - t)n-i ti Pi], where C(n, k) is the binomial coefficient defined by n! / ( k! (n-k)! ), ! being the factorial operator.
      Parameters:
      t - the fraction
      p - the points of the curve, where the first and last are begin and end point, and all intermediate ones are control points
      Returns:
      the Bézier value B(t) of degree n, where n is the number of points in the p array
    • derivative

      public static double[] derivative(double[] in)
      Returns the derivative for one dimension of a Bézier, which is a Bézier of 1 order lower.
      Parameters:
      in - coefficients of one dimension of a Bézier
      Returns:
      coefficients of one dimension of the derivative Bézier