VehicleDynamics.Utilities.Functions

VehicleDynamics.Utilities.Functions.EWM VehicleDynamics.Utilities.Functions.from_nxy VehicleDynamics.Utilities.Functions.length VehicleDynamics.Utilities.Functions.normalize

NameDescription
EWM  
from_nxy Return orientation object from n_x and n_y vectors
length Return length of a vector
normalize Return normalized vector such that length = 1


VehicleDynamics.Utilities.Functions.EWM VehicleDynamics.Utilities.Functions.EWM

Information

Element wise multiplication of vectors.

Modelica definition

function EWM 
  input Real a[:];
  input Real b[size(a, 1)];
  output Real c[size(a, 1)];
algorithm 
  
  for i in 1:size(a, 1) loop
    c[i] := a[i]*b[i];
  end for;
end EWM;

VehicleDynamics.Utilities.Functions.from_nxy VehicleDynamics.Utilities.Functions.from_nxy

Return orientation object from n_x and n_y vectors

Information


It is assumed that the two input vectors n_x and n_y are resolved in frame 1 and are directed along the x and y axis of frame 2 (i.e., n_x and n_y are orthogonal to each other) The function returns the orientation object R to rotate from frame 1 to frame 2.

The function is robust in the sense that it returns always an orientation object R, even if n_y is not orthogonal to n_x. This is performed in the following way:

If n_x and n_y are not orthogonal to each other, first a unit vector e_y is determined that is orthogonal to n_x and is lying in the plane spanned by n_x and n_y. If n_x and n_y are parallel or nearly parallel to each other, a vector e_y is selected arbitrarily such that e_x and e_y are orthogonal to each.


Modelica definition

function from_nxy 
  "Return orientation object from n_x and n_y vectors" 
  extends Modelica.Icons.Function;
  input Real n_x[3] 
    "Vector in direction of x-axis of frame 2, resolved in frame 1";
  input Real n_y[3] 
    "Vector in direction of y-axis of frame 2, resolved in frame 1";
  output Real S[3, 3] "Orientation matrix to rotate frame 1 into frame 2";
protected 
  Real abs_n_x=sqrt(n_x*n_x);
  Real e_x[3]=if abs_n_x < 1.e-10 then {1,0,0} else n_x/abs_n_x;
  Real n_z_aux[3]=cross(e_x, n_y);
  Real n_y_aux[3]=if n_z_aux*n_z_aux > 1.0e-6 then n_y else (if abs(e_x[1]) > 
      1.0e-6 then {0,1,0} else {1,0,0});
  Real e_z_aux[3]=cross(e_x, n_y_aux);
  Real e_z[3]=e_z_aux/sqrt(e_z_aux*e_z_aux);
  Real e_y[3]=cross(e_z, e_x);
algorithm 
  S := {e_x[:],e_y[:],cross(e_x[:], e_y[:])};
end from_nxy;

VehicleDynamics.Utilities.Functions.length VehicleDynamics.Utilities.Functions.length

Return length of a vector

Modelica definition

function length "Return length of a vector" 
  extends Modelica.Icons.Function;
  input Real r[:] "Vector";
  output Real r_length "length of vector r";
algorithm 
  r_length := sqrt(r*r);
end length;

VehicleDynamics.Utilities.Functions.normalize VehicleDynamics.Utilities.Functions.normalize

Return normalized vector such that length = 1

Modelica definition

function normalize "Return normalized vector such that length = 1" 
  extends Modelica.Icons.Function;
  input Real r[:] "Vector";
  output Real r_unitlength[size(r, 1)] "Input vector r normalized to length=1";
algorithm 
  r_unitlength := if length(r) > 1.e-10 then r/length(r) else r;
end normalize;

HTML-documentation generated by Dymola Fri Jul 11 13:27:46 2003 .