Sums of Forces and Moments - mkraska/meclib GitHub Wiki
Extraction of sums of forces and moments from MecLib images.
Question Variables
Unit vector from a force
object
unitvec(l):=block( [v] , v:round((l[4]-l[3])*10),v/sqrt(v[1]^2+v[2]^2));
Sign of a moment
object
msign(l):=block( [v1,v2] , v1:l[4]-l[3],v2:l[5]-l[3],round(signum(v1[1]*v2[2]-v1[2]*v2[1])));
Moment of a force object about a reference point
moment(l,p):=block( [f,r] , f:unitvec(l),r:l[3]-p, r[1]*f[2]-r[2]*f[1]);
Feedback Variables
rp
reference pointlu
symbolic length unitobjects
Input field with object listnames
Input field with object names
rp:[0,0];
lu:a;
data: stackjson_parse(objects);
f:[0,0];
for i:1 thru length(data) do ( if (data[i][1]="force") then f: f+names[i]*unitvec(data[i]));
m:0;
for i:1 thru length(data) do ( if (data[i][1]="force") then m: m+names[i]*lu*moment(data[i],rp));
for i:1 thru length(data) do ( if (data[i][1]="moment") then m: m+names[i]*msign(data[i]));
PRT Node
Display of the sum of forces and moments (use standard feedback format).
<p>\( \displaystyle \Sigma F_x={@f[1]@}\) </p>
<p>\( \displaystyle \Sigma F_y={@f[2]@}\) </p>
<p>\( \displaystyle \Sigma M_0={@m@}\) </p>