CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

function

Planning.Bezier.derivativeControlPoints

Construct control points for a physical-time derivative

Repeatedly applies the Bezier hodograph relation. Division by duration makes the result a derivative with respect to physical time rather than normalized curve parameter.

Public declarations

Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.

RoleNameTypeDimensions / attributes / defaultDescription
inputcontrolPointReal[:, :]One control point per column
inputdurationReal(unit = "s")Curve duration
inputderivativeOrderInteger(min = 0) = 1Derivative order
outputderivativePointReal[ size(controlPoint, 1), size(controlPoint, 2) - derivativeOrder]

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

function derivativeControlPoints
    "Construct control points for a physical-time derivative"
    input Real controlPoint[:, :] "One control point per column";
    input Real duration(unit = "s") "Curve duration";
    input Integer derivativeOrder(min = 0) = 1 "Derivative order";
    output Real derivativePoint[
      size(controlPoint, 1), size(controlPoint, 2) - derivativeOrder];
  protected
    Real stage[size(controlPoint, 1), size(controlPoint, 2)];
    Integer degree;
  algorithm
    assert(duration > 0.0, "Bezier duration must be positive");
    assert(derivativeOrder < size(controlPoint, 2),
      "Bezier derivative order must not exceed the curve degree");
    stage := controlPoint;
    degree := size(controlPoint, 2) - 1;
    for derivativeIndex in 1:derivativeOrder loop
      for pointIndex in 1:size(controlPoint, 2) - derivativeIndex loop
        stage[:, pointIndex] := (degree - derivativeIndex + 1)
          * (stage[:, pointIndex + 1] - stage[:, pointIndex]) / duration;
      end for;
    end for;
    derivativePoint := stage[:, 1:size(controlPoint, 2) - derivativeOrder];
    annotation(Documentation(info="<html>
      <p>Repeatedly applies the Bezier hodograph relation. Division by
      <code>duration</code> makes the result a derivative with respect to
      physical time rather than normalized curve parameter.</p>
    </html>"));
  end derivativeControlPoints;