CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

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.

RoleNameTypeDimensions / attributes / defaultDescription
inputthetaRealRotation angle [rad]
inputvReal[2]Input vector
outputv_outReal[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;