Skip to content

Commit 59a4e04

Browse files
committed
Simplify selection of constraint equations to be used (less error-prone, better understandable)
1 parent 358fedd commit 59a4e04

3 files changed

Lines changed: 36 additions & 69 deletions

File tree

Modelica/Mechanics/MultiBody/Joints/Constraints/Revolute.mo

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,36 +70,25 @@ equation
7070
r_rel_a = Frames.resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0);
7171

7272
// Constraint equations concerning translations
73-
if x_locked and y_locked and z_locked then
74-
r_rel_a=zeros(3);
75-
elseif x_locked and y_locked and not z_locked then
73+
if x_locked then
7674
r_rel_a[1]=0;
77-
r_rel_a[2]=0;
78-
frame_a.f[3]=0;
79-
elseif x_locked and not y_locked and z_locked then
80-
r_rel_a[1]=0;
81-
r_rel_a[3]=0;
82-
frame_a.f[2]=0;
83-
elseif x_locked and not y_locked and not z_locked then
84-
r_rel_a[1]=0;
85-
frame_a.f[2]=0;
86-
frame_a.f[3]=0;
87-
elseif not x_locked and y_locked and z_locked then
88-
r_rel_a[2]=0;
89-
r_rel_a[3]=0;
75+
else
9076
frame_a.f[1]=0;
91-
elseif not x_locked and y_locked and not z_locked then
77+
end if;
78+
79+
if y_locked then
9280
r_rel_a[2]=0;
93-
frame_a.f[1]=0;
94-
frame_a.f[3]=0;
95-
elseif not x_locked and not y_locked and z_locked then
96-
r_rel_a[3]=0;
97-
frame_a.f[1]=0;
81+
else
9882
frame_a.f[2]=0;
83+
end if;
84+
85+
if z_locked then
86+
r_rel_a[3]=0;
9987
else
100-
frame_a.f=zeros(3);
88+
frame_a.f[3]=0;
10189
end if;
10290

91+
10392
// Constraint equations concerning rotations
10493
0 = ex_a*R_rel.T*e;
10594
0 = ey_a*R_rel.T*e;

Modelica/Mechanics/MultiBody/Joints/Constraints/Spherical.mo

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,25 @@ equation
5252
r_rel_a = MBS.Frames.resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0);
5353

5454
// Constraint equations concerning translation
55-
if x_locked and y_locked and z_locked then
56-
r_rel_a=zeros(3);
57-
elseif x_locked and y_locked and not z_locked then
55+
if x_locked then
5856
r_rel_a[1]=0;
59-
r_rel_a[2]=0;
60-
frame_a.f[3]=0;
61-
elseif x_locked and not y_locked and z_locked then
62-
r_rel_a[1]=0;
63-
r_rel_a[3]=0;
64-
frame_a.f[2]=0;
65-
elseif x_locked and not y_locked and not z_locked then
66-
r_rel_a[1]=0;
67-
frame_a.f[2]=0;
68-
frame_a.f[3]=0;
69-
elseif not x_locked and y_locked and z_locked then
70-
r_rel_a[2]=0;
71-
r_rel_a[3]=0;
57+
else
7258
frame_a.f[1]=0;
73-
elseif not x_locked and y_locked and not z_locked then
59+
end if;
60+
61+
if y_locked then
7462
r_rel_a[2]=0;
75-
frame_a.f[1]=0;
76-
frame_a.f[3]=0;
77-
elseif not x_locked and not y_locked and z_locked then
78-
r_rel_a[3]=0;
79-
frame_a.f[1]=0;
63+
else
8064
frame_a.f[2]=0;
65+
end if;
66+
67+
if z_locked then
68+
r_rel_a[3]=0;
8169
else
82-
frame_a.f=zeros(3);
70+
frame_a.f[3]=0;
8371
end if;
8472

73+
8574
//frame_a.t = zeros(3);
8675
frame_b.t = zeros(3);
8776
frame_b.f = -MBS.Frames.resolve2(R_rel, frame_a.f);

Modelica/Mechanics/MultiBody/Joints/Constraints/Universal.mo

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,24 @@ equation
4646
r_rel_a = MBS.Frames.resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0);
4747

4848
// Constraint equations concerning translations
49-
if x_locked and y_locked and z_locked then
50-
r_rel_a=zeros(3);
51-
elseif x_locked and y_locked and not z_locked then
49+
if x_locked then
5250
r_rel_a[1]=0;
53-
r_rel_a[2]=0;
54-
frame_a.f[3]=0;
55-
elseif x_locked and not y_locked and z_locked then
56-
r_rel_a[1]=0;
57-
r_rel_a[3]=0;
58-
frame_a.f[2]=0;
59-
elseif x_locked and not y_locked and not z_locked then
60-
r_rel_a[1]=0;
61-
frame_a.f[2]=0;
62-
frame_a.f[3]=0;
63-
elseif not x_locked and y_locked and z_locked then
64-
r_rel_a[2]=0;
65-
r_rel_a[3]=0;
51+
else
6652
frame_a.f[1]=0;
67-
elseif not x_locked and y_locked and not z_locked then
53+
end if;
54+
55+
if y_locked then
6856
r_rel_a[2]=0;
69-
frame_a.f[1]=0;
70-
frame_a.f[3]=0;
71-
elseif not x_locked and not y_locked and z_locked then
72-
r_rel_a[3]=0;
73-
frame_a.f[1]=0;
57+
else
7458
frame_a.f[2]=0;
59+
end if;
60+
61+
if z_locked then
62+
r_rel_a[3]=0;
7563
else
76-
frame_a.f=zeros(3);
64+
frame_a.f[3]=0;
7765
end if;
66+
7867
// Constraint equations concerning rotations
7968
frame_a.t*n_a=0;
8069
frame_b.t*n_b=0;

0 commit comments

Comments
 (0)