MGAircraftTrifilarPendulumStaticsFBD.html  (MotionGenesis input/output).
```   (1) % MotionGenesis file:  MGAircraftTrifilarPendulumStaticsFBD.txt
(2) % Copyright (c) 2016-18 Motion Genesis LLC.
(3) %--------------------------------------------------------------------
(4) SetAutoZ( OFF )
(5) NewtonianFrame  N                    % Earth / aircraft hanger.
(6) RigidBody       C                    % Aircraft.
(7) Point           N1(N), N2(N), N3(N)  % End-points of cable on N.
(8) Point           C1(C), C2(C), C3(C)  % End-points of cable on C.
(9) %--------------------------------------------------------------------
(10) Constant  L1 = 30 m                  % Length of cable between N1 and C1.
(11) Constant  L2 = 30 m                  % Length of cable between N2 and C2.
(12) Constant  L3 = 30 m                  % Length of cable between N3 and C3.
(13) Constant  dN = 30 m                  % Distance between No and N1.
(14) Constant  dC = 30 m                  % Distance between Co and C1.
(15) Constant  wN = 20 m                  % Distance between No and N2.
(16) Constant  wC = 20 m                  % Distance between Co and C2.
(17) Constant dcm =  8 m                  % Distance between Co and Ccm.
(18) Constant  g = 9.8 m/s^2              % Earth's gravitational acceleration.
(19) Variable  x,   y,   z                % Locates Ccm from No.
(20) Variable  q1,  q2,  q3               % BodyZYX Euler angles.
(21) Variable  T1, T2, T3                 % Tension in cables.
(22) C.SetMass( m = 9000 kg )
(23) %--------------------------------------------------------------------
(24) %   Rotational and translational kinematics.
(25) C.SetRotationMatrix( N, BodyZYX, q1, q2, q3 )
-> (26) C_N[1,1] = cos(q1)*cos(q2)
-> (27) C_N[1,2] = sin(q1)*cos(q2)
-> (28) C_N[1,3] = -sin(q2)
-> (29) C_N[2,1] = sin(q2)*sin(q3)*cos(q1) - sin(q1)*cos(q3)
-> (30) C_N[2,2] = cos(q1)*cos(q3) + sin(q1)*sin(q2)*sin(q3)
-> (31) C_N[2,3] = sin(q3)*cos(q2)
-> (32) C_N[3,1] = sin(q1)*sin(q3) + sin(q2)*cos(q1)*cos(q3)
-> (33) C_N[3,2] = sin(q1)*sin(q2)*cos(q3) - sin(q3)*cos(q1)
-> (34) C_N[3,3] = cos(q2)*cos(q3)

(35) CCm.SetPosition( No, x*Nx> + y*Ny> + z*Nz> )
-> (36) p_No_Ccm> = x*Nx> + y*Ny> + z*Nz>

(37) Co.SetPosition( CCm, -dcm*Cx> )
-> (38) p_Ccm_Co> = -dcm*Cx>

(39) C1.SetPosition( Co,    dC*Cx> )
-> (40) p_Co_C1> = dC*Cx>

(41) C2.SetPosition( Co,   -wC*Cy> )
-> (42) p_Co_C2> = -wC*Cy>

(43) C3.SetPosition( Co,    wC*Cy> )
-> (44) p_Co_C3> = wC*Cy>

(45) N1.SetPosition( No,    dN*Nx> )
-> (46) p_No_N1> = dN*Nx>

(47) N2.SetPosition( No,   -wN*Ny> )
-> (48) p_No_N2> = -wN*Ny>

(49) N3.SetPosition( No,    wN*Ny> )
-> (50) p_No_N3> = wN*Ny>

(51) %--------------------------------------------------------------------
(52) %   Configuration constraints: Length of cables.
(53) CableConstraint[1] = C1.GetDistanceSquared( N1 ) - L1^2
-> (54) CableConstraint[1] = (dC-dcm)^2 + y^2 + z^2 + (dN-x)^2 + 2*(dC-dcm)*y*
sin(q1)*cos(q2) - L1^2 - 2*(dC-dcm)*z*sin(q2) - 2*(dC-dcm)*cos(q1)*cos(
q2)*(dN-x)

(55) CableConstraint[2] = C2.GetDistanceSquared( N2 ) - L2^2
-> (56) CableConstraint[2] = dcm^2 + wC^2 + x^2 + z^2 + (wN+y)^2 + 2*dcm*z*sin(q2)
+ 2*wC*x*(sin(q1)*cos(q3)-sin(q2)*sin(q3)*cos(q1)) - L2^2 - 2*dcm*x*cos
(q1)*cos(q2) - 2*wC*z*sin(q3)*cos(q2) - 2*dcm*sin(q1)*cos(q2)*(wN+y)
- 2*wC*(wN+y)*(cos(q1)*cos(q3)+sin(q1)*sin(q2)*sin(q3))

(57) CableConstraint[3] = C3.GetDistanceSquared( N3 ) - L3^2
-> (58) CableConstraint[3] = dcm^2 + wC^2 + x^2 + z^2 + (wN-y)^2 + 2*dcm*z*sin(q2)
+ 2*wC*z*sin(q3)*cos(q2) + 2*dcm*sin(q1)*cos(q2)*(wN-y) - L3^2 - 2*dcm*
x*cos(q1)*cos(q2) - 2*wC*x*(sin(q1)*cos(q3)-sin(q2)*sin(q3)*cos(q1))
- 2*wC*(wN-y)*(cos(q1)*cos(q3)+sin(q1)*sin(q2)*sin(q3))

(59) %--------------------------------------------------------------------
(60) %   Add forces from gravity and tension.
-> (62) Force_Ccm> = m*g*Nz>

(63) unitVectorToN1FromC1> = N1.GetPosition(C1) / L1
-> (64) unitVectorToN1FromC1> = -(dC-dcm)/L1*Cx> + (dN-x)/L1*Nx> - y/L1*Ny> - z/L1*Nz>

(65) unitVectorToN2FromC2> = N2.GetPosition(C2) / L2
-> (66) unitVectorToN2FromC2> = dcm/L2*Cx> + wC/L2*Cy> - x/L2*Nx> - (wN+y)/L2*Ny> - z/L2*Nz>

(67) unitVectorToN3FromC3> = N3.GetPosition(C3) / L3
-> (68) unitVectorToN3FromC3> = dcm/L3*Cx> - wC/L3*Cy> - x/L3*Nx> + (wN-y)/L3*Ny> - z/L3*Nz>

(69) C1.AddForce( N1,  T1 * unitVectorToN1FromC1>  )
-> (70) Force_C1_N1> = -(dC-dcm)*T1/L1*Cx> + T1*(dN-x)/L1*Nx> - T1*y/L1*Ny>
- T1*z/L1*Nz>

(71) C2.AddForce( N2,  T2 * unitVectorToN2FromC2>  )
-> (72) Force_C2_N2> = dcm*T2/L2*Cx> + wC*T2/L2*Cy> - T2*x/L2*Nx> - T2*(wN+y)/L2*Ny>
- T2*z/L2*Nz>

(73) C3.AddForce( N3,  T3 * unitVectorToN3FromC3>  )
-> (74) Force_C3_N3> = dcm*T3/L3*Cx> - wC*T3/L3*Cy> - T3*x/L3*Nx> + T3*(wN-y)/L3*Ny>
- T3*z/L3*Nz>

(75) %--------------------------------------------------------------------
(76) %   Calculate resultant force on C in terms of Fx, Fy, Fz.
(77) ResultantForce> = C.GetResultantForce()
-> (78) ResultantForce> = (dcm*T2/L2+dcm*T3/L3-(dC-dcm)*T1/L1)*Cx> + wC*(T2/L2-
T3/L3)*Cy> + (T1*(dN-x)/L1-T2*x/L2-T3*x/L3)*Nx> + (T3*(wN-y)/L3-T1*y/L1
-T2*(wN+y)/L2)*Ny> + (m*g-T1*z/L1-T2*z/L2-T3*z/L3)*Nz>

(79) Fx = Dot(  ResultantForce>,  Nx>  )
-> (80) Fx = T1*(dN-x)/L1 + cos(q1)*cos(q2)*(dcm*T2/L2+dcm*T3/L3-(dC-dcm)*T1/L1)
- T2*x/L2 - T3*x/L3 - wC*(T2/L2-T3/L3)*(sin(q1)*cos(q3)-sin(q2)*sin(q3)
*cos(q1))

(81) Fy = Dot(  ResultantForce>,  Ny>  )
-> (82) Fy = T3*(wN-y)/L3 + sin(q1)*cos(q2)*(dcm*T2/L2+dcm*T3/L3-(dC-dcm)*T1/L1)
+ wC*(T2/L2-T3/L3)*(cos(q1)*cos(q3)+sin(q1)*sin(q2)*sin(q3)) - T1*y/L1
- T2*(wN+y)/L2

(83) Fz = Dot(  ResultantForce>,  Nz>  )
-> (84) Fz = m*g + wC*sin(q3)*cos(q2)*(T2/L2-T3/L3) - T1*z/L1 - T2*z/L2 - T3*z/L3
- sin(q2)*(dcm*T2/L2+dcm*T3/L3-(dC-dcm)*T1/L1)

(85) %--------------------------------------------------------------------
(86) %   Calculate moment of all forces on C about Ccm in terms of Mx, My, Mz.
(87) ResultantMoment> = C.GetMomentOfForces( Ccm )
-> (88) ResultantMoment> = (T3*(dcm*z*sin(q1)*cos(q2)-dcm*sin(q2)*(wN-y)-wC*sin
(q3)*cos(q2)*(wN-y)-wC*z*(cos(q1)*cos(q3)+sin(q1)*sin(q2)*sin(q3)))/L3-
(dC-dcm)*T1*(y*sin(q2)+z*sin(q1)*cos(q2))/L1-T2*(wC*sin(q3)*cos(q2)*(
wN+y)-dcm*sin(q2)*(wN+y)-dcm*z*sin(q1)*cos(q2)-wC*z*(cos(q1)*cos(q3)+
sin(q1)*sin(q2)*sin(q3)))/L2)*Nx> + ((dC-dcm)*T1*(z*cos(q1)*cos(q2)-sin
(q2)*(dN-x))/L1-T3*(dcm*x*sin(q2)+dcm*z*cos(q1)*cos(q2)+wC*x*sin(q3)*
cos(q2)+wC*z*(sin(q1)*cos(q3)-sin(q2)*sin(q3)*cos(q1)))/L3-T2*(dcm*x*
sin(q2)+dcm*z*cos(q1)*cos(q2)-wC*x*sin(q3)*cos(q2)-wC*z*(sin(q1)*cos(
q3)-sin(q2)*sin(q3)*cos(q1)))/L2)*Ny> + (T2*(dcm*cos(q1)*cos(q2)*(wN+y)
-dcm*x*sin(q1)*cos(q2)-wC*x*(cos(q1)*cos(q3)+sin(q1)*sin(q2)*sin(q3))-
wC*(wN+y)*(sin(q1)*cos(q3)-sin(q2)*sin(q3)*cos(q1)))/L2+T3*(wC*x*(cos(
q1)*cos(q3)+sin(q1)*sin(q2)*sin(q3))-dcm*x*sin(q1)*cos(q2)-dcm*cos(q1)*
cos(q2)*(wN-y)-wC*(wN-y)*(sin(q1)*cos(q3)-sin(q2)*sin(q3)*cos(q1)))/L3-
(dC-dcm)*T1*cos(q2)*(y*cos(q1)+sin(q1)*(dN-x))/L1)*Nz>

(89) Mx = Dot(  ResultantMoment>,  Cx>  )
-> (90) Mx = -wC*(T3*(x*sin(q1)*sin(q3)+z*cos(q2)*cos(q3)+sin(q3)*cos(q1)*(wN-y))
/L3-T2*(x*sin(q1)*sin(q3)+z*cos(q2)*cos(q3)-sin(q3)*cos(q1)*(wN+y))/L2-
sin(q2)*cos(q3)*(T2*(x*cos(q1)+sin(q1)*(wN+y))/L2-T3*(x*cos(q1)-sin(q1)
*(wN-y))/L3))

(91) My = Dot(  ResultantMoment>,  Cy>  )
-> (92) My = (sin(q1)*cos(q3)-sin(q2)*sin(q3)*cos(q1))*((dC-dcm)*T1*(y*sin(q2)+
z*sin(q1)*cos(q2))/L1-dcm*T2*(sin(q2)*(wN+y)+z*sin(q1)*cos(q2))/L2-dcm*
T3*(z*sin(q1)*cos(q2)-sin(q2)*(wN-y))/L3) - sin(q3)*cos(q2)^2*(dcm*T2*(
x*sin(q1)-cos(q1)*(wN+y))/L2+dcm*T3*(x*sin(q1)+cos(q1)*(wN-y))/L3+(dC-
dcm)*T1*(y*cos(q1)+sin(q1)*(dN-x))/L1) - (cos(q1)*cos(q3)+sin(q1)*sin(
q2)*sin(q3))*(dcm*T2*(x*sin(q2)+z*cos(q1)*cos(q2))/L2+dcm*T3*(x*sin(q2)
+z*cos(q1)*cos(q2))/L3-(dC-dcm)*T1*(z*cos(q1)*cos(q2)-sin(q2)*(dN-x))/L1)

(93) Mz = Dot(  ResultantMoment>,  Cz>  )
-> (94) Mz = -(sin(q3)*cos(q1)-sin(q1)*sin(q2)*cos(q3))*((dC-dcm)*T1*(z*cos(q1)
*cos(q2)-sin(q2)*(dN-x))/L1-T3*(dcm*x*sin(q2)+dcm*z*cos(q1)*cos(q2)+wC*
x*sin(q3)*cos(q2)+wC*z*(sin(q1)*cos(q3)-sin(q2)*sin(q3)*cos(q1)))/L3-
T2*(dcm*x*sin(q2)+dcm*z*cos(q1)*cos(q2)-wC*x*sin(q3)*cos(q2)-wC*z*(sin(
q1)*cos(q3)-sin(q2)*sin(q3)*cos(q1)))/L2) - (sin(q1)*sin(q3)+sin(q2)*
cos(q1)*cos(q3))*((dC-dcm)*T1*(y*sin(q2)+z*sin(q1)*cos(q2))/L1+T2*(wC*
sin(q3)*cos(q2)*(wN+y)-dcm*sin(q2)*(wN+y)-dcm*z*sin(q1)*cos(q2)-wC*z*(
cos(q1)*cos(q3)+sin(q1)*sin(q2)*sin(q3)))/L2-T3*(dcm*z*sin(q1)*cos(q2)-
dcm*sin(q2)*(wN-y)-wC*sin(q3)*cos(q2)*(wN-y)-wC*z*(cos(q1)*cos(q3)+sin(
q1)*sin(q2)*sin(q3)))/L3) - cos(q2)*cos(q3)*((dC-dcm)*T1*cos(q2)*(y*cos
(q1)+sin(q1)*(dN-x))/L1-T2*(dcm*cos(q1)*cos(q2)*(wN+y)-dcm*x*sin(q1)*
cos(q2)-wC*x*(cos(q1)*cos(q3)+sin(q1)*sin(q2)*sin(q3))-wC*(wN+y)*(sin(
q1)*cos(q3)-sin(q2)*sin(q3)*cos(q1)))/L2-T3*(wC*x*(cos(q1)*cos(q3)+sin(
q1)*sin(q2)*sin(q3))-dcm*x*sin(q1)*cos(q2)-dcm*cos(q1)*cos(q2)*(wN-y)-
wC*(wN-y)*(sin(q1)*cos(q3)-sin(q2)*sin(q3)*cos(q1)))/L3)

(95) %--------------------------------------------------------------------
(96) %   For statics: Resultant force and moment on aircraft is zero.
(97) Statics = [ Fx;  Fy;  Fz;   Mx;  My;  Mz ]
-> (98) Statics = [Fx;  Fy;  Fz;  Mx;  My;  Mz]

(99) %--------------------------------------------------------------------
(100) %   Statics analysis 1:  Equal-length cables  L1 = L2 = L3 = 30 m.
(101) SolveSetInput( [Statics;  CableConstraint] = 0,  q1=0 deg,  q2=0 deg,  q3=0 deg,  x = Input(dN)/2 m,  y=0 m,  z = Input(L1) m,  &
T1 = Input(m*g)/2 N,  T2 = Input(m*g)/4 N,  T3 = Input(m*g)/4 N )

->    %  INPUT has been assigned as follows:
->    %   q1                       -9.32255328875801E-19    deg
->    %   q2                        1.401784904724565E-15   deg
->    %   q3                        2.643830086946405E-16   deg
->    %   x                         8                       m
->    %   y                         1.011944434231034E-18   m
->    %   z                         30                      m
->    %   T1                        23520                   N
->    %   T2                        32340                   N
->    %   T3                        32340                   N

(102) %--------------------------------------------------------------------
(103) %   Statics analysis 2:  Unequal-length cables  L1 = L2 = 22 m,   L3 = 30 m.
(104) Input  L1 := 22 m,  L2 := 22 m,  L3 := 30 m
(105) SolveSetInput( [Statics;  CableConstraint] = 0,  q1=0 deg,  q2=0 deg,  q3=0 deg,  x = Input(dN)/2 m,  y=0 m,  z = Input(L1) m,  &
T1 = Input(m*g)/2 N,  T2 = Input(m*g)/4 N,  T3 = Input(m*g)/4 N )

->    %  INPUT has been assigned as follows:
->    %   q1                        0.9593486506940127      deg
->    %   q2                        7.659043192403293       deg
->    %   q3                        11.63295584237929       deg
->    %   x                         8.031358951235374       m
->    %   y                        -0.05976274847707991     m
->    %   z                         24.92935115026748       m
->    %   T1                        23615.15761570217       N
->    %   T2                        32427.5589998023        N
->    %   T3                        32170.25182512401       N

(106) %--------------------------------------------------------------------
(107) %   Calculate yaw, pitch and roll angles in terms of q1, q2, q3.
(108) Yaw   = GetAngleBetweenUnitVectors( Nx>, Cy> )  -  pi/2
-> (109) Yaw = -1.570796 + acos(sin(q2)*sin(q3)*cos(q1)-sin(q1)*cos(q3))

(110) Pitch = GetAngleBetweenUnitVectors( Nz>, Cx> )  -  pi/2
-> (111) Pitch = 1.570796 - acos(sin(q2))

(112) Roll  = pi/2  -  GetAngleBetweenUnitVectors( Nz>, Cy> )
-> (113) Roll = 1.570796 - acos(sin(q3)*cos(q2))

(114) %--------------------------------------------------------------------
(115) %   Numerical values.
(116) DistanceStatic     = EvaluateToNumber( Co.GetDistance(No) )
-> (117) DistanceStatic = 25.99649

(118) YawStaticDegrees   = EvaluateToNumber( Yaw )   *  180/pi
-> (119) YawStaticDegrees = -0.5999802

(120) PitchStaticDegrees = EvaluateToNumber( Pitch ) *  180/pi
-> (121) PitchStaticDegrees = 7.659043

(122) RollStaticDegrees  = EvaluateToNumber( Roll )  *  180/pi
-> (123) RollStaticDegrees = 11.52774

(124) %--------------------------------------------------------------------
```