function
LieGroups.SO2.rotate
Rotate a 2D vector by angle theta
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | theta | Real | | Rotation angle [rad] |
| input | v | Real | [2] | Input vector |
| output | v_out | Real | [2] | Rotated vector |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function rotate "Rotate a 2D vector by angle theta"
input Real theta "Rotation angle [rad]";
input Real v[2] "Input vector";
output Real v_out[2] "Rotated vector";
protected
Real c, s;
algorithm
c := cos(theta);
s := sin(theta);
v_out[1] := c*v[1] - s*v[2];
v_out[2] := s*v[1] + c*v[2];
end rotate;