Ticket #1139: 1139.mo

File 1139.mo, 1.7 KB (added by sjoelund.se, 15 years ago)

Works For Me (TM): Attached the actual output from OpenModelica r4842

Line 
1package Modelica
2package Constants
3constant Real eps = 0.001;
4end Constants;
5end Modelica;
6
7function normalize
8  input Real v[:];
9  input Real eps = 100 * Modelica.Constants.eps;
10  output Real result[size(v, 1)];
11algorithm 
12  result := smooth(0, if length(v) >= eps then v / length(v) else v / eps);
13end normalize;
14
15class _1139
16  Real n_z_aux = 1;
17  Real widthDirection[3] = {0,1,0};
18  Real e_x[3] = {1,1,1};
19  Real e_y[3](each final unit="1") = noEvent(
20    cross(normalize(
21              cross(e_x, if n_z_aux*n_z_aux > 1e-06 then widthDirection else if abs(e_x[1]) > 1e-06 then {0,1,0} else {1,0,0})
22          ),
23          e_x)
24  );
25end _1139;
26
27// fclass _1139
28// Real n_z_aux = 1.0;
29// Real widthDirection[1] = 0.0;
30// Real widthDirection[2] = 1.0;
31// Real widthDirection[3] = 0.0;
32// Real e_x[1] = 1.0;
33// Real e_x[2] = 1.0;
34// Real e_x[3] = 1.0;
35// Real e_y[1](unit = "1") = cross(normalize(cross({e_x[1],e_x[2],e_x[3]},if noEvent(n_z_aux ^ 2.0 > 1e-06) then {widthDirection[1],widthDirection[2],widthDirection[3]} else if noEvent(abs(e_x[1]) > 1e-06) then {0.0,1.0,0.0} else {1.0,0.0,0.0}),0.1),{e_x[1],e_x[2],e_x[3]})[1];
36// Real e_y[2](unit = "1") = cross(normalize(cross({e_x[1],e_x[2],e_x[3]},if noEvent(n_z_aux ^ 2.0 > 1e-06) then {widthDirection[1],widthDirection[2],widthDirection[3]} else if noEvent(abs(e_x[1]) > 1e-06) then {0.0,1.0,0.0} else {1.0,0.0,0.0}),0.1),{e_x[1],e_x[2],e_x[3]})[2];
37// Real e_y[3](unit = "1") = cross(normalize(cross({e_x[1],e_x[2],e_x[3]},if noEvent(n_z_aux ^ 2.0 > 1e-06) then {widthDirection[1],widthDirection[2],widthDirection[3]} else if noEvent(abs(e_x[1]) > 1e-06) then {0.0,1.0,0.0} else {1.0,0.0,0.0}),0.1),{e_x[1],e_x[2],e_x[3]})[3];
38// end _1139;
39