function
Planning.Bezier.evaluate
Evaluate a dimension-generic Bezier curve using De Casteljau's algorithm
Evaluates a Bezier curve without forming Bernstein polynomials. Rows are independent signal dimensions and columns are control points.
t is intentionally not clipped; values outside
[0, duration] extrapolate the polynomial.
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | controlPoint | Real | [:, :] | One control point per column |
| input | duration | Real | (unit = "s") | Curve duration |
| input | t | Real | (unit = "s") | Time relative to the segment start |
| output | value | Real | [size(controlPoint, 1)] | Curve value at t |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function evaluate
"Evaluate a dimension-generic Bezier curve using De Casteljau's algorithm"
input Real controlPoint[:, :] "One control point per column";
input Real duration(unit = "s") "Curve duration";
input Real t(unit = "s") "Time relative to the segment start";
output Real value[size(controlPoint, 1)] "Curve value at t";
protected
Real stage[size(controlPoint, 1), size(controlPoint, 2)];
Real beta(unit = "1") "Normalized curve parameter";
algorithm
assert(duration > 0.0, "Bezier duration must be positive");
assert(size(controlPoint, 2) >= 1,
"A Bezier curve requires at least one control point");
beta := t / duration;
stage := controlPoint;
for level in 1:size(controlPoint, 2) - 1 loop
for pointIndex in 1:size(controlPoint, 2) - level loop
stage[:, pointIndex] := (1.0 - beta) * stage[:, pointIndex]
+ beta * stage[:, pointIndex + 1];
end for;
end for;
value := stage[:, 1];
annotation(Documentation(info="<html>
<p>Evaluates a Bezier curve without forming Bernstein polynomials.
Rows are independent signal dimensions and columns are control points.</p>
<p><code>t</code> is intentionally not clipped; values outside
<code>[0, duration]</code> extrapolate the polynomial.</p>
</html>"));
end evaluate;