MGBeamOnTwoCablesStaticsViaKaneLagrangeAugmentConstraints.html  (MotionGenesis input/output).
   (1) %    File: MGBeamOnTwoCablesStaticsViaKaneLagrangeAugmentConstraints.txt
   (2) % Problem: Static configuration of a beam supported by two cables.
   (3) %--------------------------------------------------------------------
   (4) NewtonianFrame N         % Ceiling with Nx> horizontally right, Ny> vertically down
   (5) RigidBody      B         % Beam with Bx> pointing from Bo to Bc and Bz> = Nz>.
   (6) Point          Nc( N )   % Point of N attached to cable C.
   (7) Point          Bc( B )   % Point of B attached to cable C.
   (8) %--------------------------------------------------------------------
   (9) Constant  LN = 6 m       % Distance between No and NC.
   (10) Constant  LB = 4 m       % Distance between Bo and BC.
   (11) Constant  LA = 2.7 m     % Length of cable A (connects Bo to No).
   (12) Constant  LC = 3.7 m     % Length of cable C (connects BC to NC).
   (13) Constant  g = 9.8 m/s^2  % Earth's gravitational acceleration.
   (14) B.SetMass( m = 120 kg )
   (15) %--------------------------------------------------------------------
   (16) Variable  x', y'         % Nx> and Ny> measures of Bo's position vector from No.
   (17) Variable  q'             % Angle from Nx> to Bx> with positive sense +Nz>.
   (18) Variable  TA, TC         % Tensions in cables A and C.
   (19) %--------------------------------------------------------------------
   (20) %   Rotational kinematics relating  Bx>, By>, Bz>  to  Nx>, Ny>, Nz>.
   (21) B.RotateZ( N,  q )
-> (22) B_N = [cos(q), sin(q), 0;  -sin(q), cos(q), 0;  0, 0, 1]
-> (23) w_B_N> = q'*Bz>

   (24) %--------------------------------------------------------------------
   (25) %   Position and velocity vectors (for partial velocities).
   (26) Bo.SetPositionVelocity( No,  x*Nx> + y*Ny> )
-> (27) p_No_Bo> = x*Nx> + y*Ny>
-> (28) v_Bo_N> = x'*Nx> + y'*Ny>

   (29) Bcm.SetPositionVelocity( Bo,  0.5*LB*Bx> )
-> (30) p_Bo_Bcm> = 0.5*LB*Bx>
-> (31) v_Bcm_N> = 0.5*LB*q'*By> + x'*Nx> + y'*Ny>

   (32) BC.SetPositionVelocity( Bo,  LB*Bx> )
-> (33) p_Bo_Bc> = LB*Bx>
-> (34) v_Bc_N> = LB*q'*By> + x'*Nx> + y'*Ny>

   (35) NC.SetPosition( No,  LN*Nx> )
-> (36) p_No_Nc> = LN*Nx>

   (37) %--------------------------------------------------------------------
   (38) %   Constraint relating cable lengths to magnitudes of position vectors.
   (39) LengthConstraint[1] = LA^2 - Bo.GetDistanceSquared( No )
-> (40) LengthConstraint[1] = LA^2 - x^2 - y^2

   (41) LengthConstraint[2] = LC^2 - Bc.GetDistanceSquared( Nc )
-> (42) LengthConstraint[2] = LC^2 + 2*LB*cos(q)*(LN-x) - LB^2 - y^2 - 2*LB*y*sin(q)
        - (LN-x)^2

   (43) %--------------------------------------------------------------------
   (44) %   Forces on beam.
   (45) unitVectorBoToNo> = No.GetPositionVector(Bo) / LA
-> (46) unitVectorBoToNo> = -x/LA*Nx> - y/LA*Ny>

   (47) unitVectorBcToNc> = NC.GetPositionVector(Bc) / LC
-> (48) unitVectorBcToNc> = -LB/LC*Bx> + (LN-x)/LC*Nx> - y/LC*Ny>

   (49) Bo.AddForce( TA*unitVectorBoToNo> )
-> (50) Force_Bo> = -TA*x/LA*Nx> - TA*y/LA*Ny>

   (51) BC.AddForce( TC*unitVectorBcToNc> )
-> (52) Force_Bc> = -LB*TC/LC*Bx> + TC*(LN-x)/LC*Nx> - TC*y/LC*Ny>

   (53) Bcm.AddForce( m*g*Ny> )
-> (54) Force_Bcm> = m*g*Ny>

   (55) %--------------------------------------------------------------------
   (56) %   Statics via Kane's augmented constraint method.
   (57) %   Constraints are not embedded -- instead they are augmented (next step).
   (58) SetGeneralizedSpeed( x', y', q' )
   (59) Statics = System.GetStaticsKane()
-> (60) Statics[1] = TC*(LN-x-LB*cos(q))/LC - TA*x/LA
-> (61) Statics[2] = m*g - TA*y/LA - TC*(y+LB*sin(q))/LC
-> (62) Statics[3] = 0.5*LB*(m*g*cos(q)-2*TC*(y*cos(q)+sin(q)*(LN-x))/LC)

   (63) %--------------------------------------------------------------------
   (64) %   Solve set of 5 nonlinear algebraic equations (with guess).
   (65) %   Note: Configuration does not depend on mass or gravity (but cable tensions do).
   (66) Solve( [Statics; LengthConstraint] = 0,   x = 1 m,  y = 3 m,  q = 15 deg,  TA = m*g/2, TC = m*g/2 )
-> (67) x = 0.8153669
-> (68) y = 2.573942
-> (69) q = 0.2257464       %  or  q = 12.93432 deg.
-> (70) TA = 665.1907
-> (71) TC = 577.9024

   (72) %--------------------------------------------------------------------
   (73) %   Post-process: Calculate distance between No and Bcm.
   (74) distanceNoToBcm = EvaluateToNumber(  Bcm.GetDistance(No)  )
-> (75) distanceNoToBcm = 4.095517

   (76) %--------------------------------------------------------------------
   (77) %   Save input and output responses.
Saved by Motion Genesis LLC.   Command names and syntax: Copyright (c) 2009-2019 Motion Genesis LLC. All rights reserved.