MGBeamOnTwoCablesStaticsViaKaneEmbedConstraints.html  (MotionGenesis input/output).
   (1) %    File: MGBeamOnTwoCablesStaticsViaKaneEmbedConstraints.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) %--------------------------------------------------------------------
   (19) %   Rotational kinematics relating  Bx>, By>, Bz>  to  Nx>, Ny>, Nz>.
   (20) B.RotateZ( N,  q )
-> (21) B_N = [cos(q), sin(q), 0;  -sin(q), cos(q), 0;  0, 0, 1]
-> (22) w_B_N> = q'*Bz>

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

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

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

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

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

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

   (42) %--------------------------------------------------------------------
   (43) %   Relevant forces on beam (to calculate generalized forces).
   (44) %   Note: Cable tensions TA and TC do not contributes to generalized force
   (45) %   because both LengthConstraint[1] and LengthConstraint[2] are embedded.
   (46) Bcm.AddForce( m*g*Ny> )
-> (47) Force_Bcm> = m*g*Ny>

   (48) %--------------------------------------------------------------------
   (49) %   Differentiate length constraints to solve for y' and q' in terms of x'.
   (50) Solve( Dt(LengthConstraint) = 0,   y',  q' )
-> (51) y' = -x*x'/y
-> (52) q' = -(LB*cos(q)-LN-LB*x*sin(q)/y)*x'/(LB*(y*cos(q)+sin(q)*(LN-x)))

   (53) %--------------------------------------------------------------------
   (54) %   Statics via Kane's embedded method (y' and q' are in terms of x').
   (55) %   This method embeds both LengthConstraint[1] and LengthConstraint[2].
   (56) SetGeneralizedSpeed( x' )
   (57) Statics = System.GetStaticsKane()
-> (58) Statics[1] = -0.5*m*g*(2*x/y+cos(q)*(LB*cos(q)-LN-LB*x*sin(q)/y)/(y*cos
        (q)+sin(q)*(LN-x)))

   (59) %--------------------------------------------------------------------
   (60) %   Solve set of 3 nonlinear algebraic equations (with guess).
   (61) Solve( [Statics; LengthConstraint] = 0,   x = 1 m,  y = 3 m,  q = 15 deg )
-> (62) x = 0.8153669
-> (63) y = 2.573942
-> (64) q = 0.2257464       %  or  q = 12.93432 deg.

   (65) %--------------------------------------------------------------------
   (66) %   Post-process: Calculate distance between No and Bcm.
   (67) distanceNoToBcm = EvaluateToNumber(  Bcm.GetDistance(No)  )
-> (68) distanceNoToBcm = 4.095517

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