Class ContinuousBezierCubic

java.lang.Object
org.opentrafficsim.core.geometry.ContinuousBezier
org.opentrafficsim.core.geometry.ContinuousBezierCubic
All Implemented Interfaces:
ContinuousLine

public class ContinuousBezierCubic extends ContinuousBezier implements ContinuousLine
Continuous definition of a cubic Bezier. This extends from the more general ContinuousBezier as certain methods are applied to calculate e.g. the roots, that are specific to cubic Beziers. With such information this class can also specify information to be a ContinuousLine.

Copyright (c) 2023-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Wouter Schakel
See Also:
  • Constructor Details

    • ContinuousBezierCubic

      public ContinuousBezierCubic(org.djutils.draw.point.Point2d point1, org.djutils.draw.point.Point2d point2, org.djutils.draw.point.Point2d point3, org.djutils.draw.point.Point2d point4)
      Create a cubic Bezier.
      Parameters:
      point1 - Point2d; start point.
      point2 - Point2d; first intermediate shape point.
      point3 - Point2d; second intermediate shape point.
      point4 - Point2d; end point.
  • Method Details

    • getStartPoint

      public org.djutils.draw.point.OrientedPoint2d getStartPoint()
      Start point.
      Specified by:
      getStartPoint in interface ContinuousLine
      Returns:
      OrientedPoint2d; start point.
    • getEndPoint

      public org.djutils.draw.point.OrientedPoint2d getEndPoint()
      End point.
      Specified by:
      getEndPoint in interface ContinuousLine
      Returns:
      OrientedPoint2d; end point.
    • getStartCurvature

      public double getStartCurvature()
      Start curvature.
      Specified by:
      getStartCurvature in interface ContinuousLine
      Returns:
      double; start curvature.
    • getEndCurvature

      public double getEndCurvature()
      End curvature.
      Specified by:
      getEndCurvature in interface ContinuousLine
      Returns:
      double; end curvature.
    • getT

      public double getT(double len)
      Returns the t value at the provided length along the Bezier. This method uses an iterative approach with a precision of 1e-6.
      Parameters:
      len - double; length along the Bezier.
      Returns:
      double; t value at the provided length along the Bezier.
    • split

      public ContinuousBezierCubic[] split(double t)
      Splits the Bezier in two Beziers of the same order.
      Parameters:
      t - double; t value along the Bezier to apply the split.
      Returns:
      ContinuousBezierCubic[]; the Bezier before t, and the Bezier after t.
    • flatten

      public org.djutils.draw.line.PolyLine2d flatten(Flattener flattener)
      Flatten continuous line in to a polyline. Implementations should use the flattener when relevant and possible.
      Specified by:
      flatten in interface ContinuousLine
      Parameters:
      flattener - Flattener; flattener.
      Returns:
      PolyLine2d; flattened line.
    • flattenOffset

      public org.djutils.draw.line.PolyLine2d flattenOffset(FractionalLengthData offsets, Flattener flattener)
      Flatten continuous line offset in to a polyline. Implementations should use the flattener when relevant and possible.
      Specified by:
      flattenOffset in interface ContinuousLine
      Parameters:
      offsets - FractionalLengthData; offset data.
      flattener - Flattener; flattener.
      Returns:
      PolyLine2d; flattened line.
    • getLength

      public double getLength()
      Return the length of the line.
      Specified by:
      getLength in interface ContinuousLine
      Returns:
      double; length of the line.
    • toString

      public String toString()
      Overrides:
      toString in class ContinuousBezier