%23%20%2F%2F%2F%20script%0A%23%20requires-python%20%3D%20%22%3E%3D3.11%22%0A%23%20dependencies%20%3D%20%5B%22marimo%3E%3D0.23.9%22%2C%20%22numpy%3E%3D2.0%22%2C%20%22matplotlib%3E%3D3.9%22%2C%20%22urllib3%3E%3D2.2%22%5D%0A%23%20%2F%2F%2F%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.25.2%22%0Aapp%20%3D%20marimo.App()%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Three-dimensional%20rigid%20body%20kinetics%0A%0A%20%20%20%20%3E%20Renato%20Naville%20Watanabe%2C%20Marcos%20Duarte%3Cbr%3E%0A%20%20%20%20%3E%20%5BLaboratory%20of%20Biomechanics%20and%20Motor%20Control%5D(https%3A%2F%2Fbmclab.pesquisa.ufabc.edu.br%2F)%3Cbr%3E%0A%20%20%20%20%3E%20Federal%20University%20of%20ABC%2C%20Brazil%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20How%20to%20use%20this%20guide%0A%0A%20%20%20%20We%20will%20track%20angular%20momentum%20in%20laboratory%20and%20body%20frames%2C%20use%20principal%20inertias%2C%20and%20compare%20the%20equations%20with%20pendulum%20and%20posture%20data.%20Label%20the%20frame%20of%20every%20vector%20before%20taking%20a%20cross%20product%20or%20a%20derivative.%0A%0A%20%20%20%20Try%20the%20distributed%20**Exercises**%20before%20opening%20their%20collapsed%20worked%20solutions.%20Then%20use%20the%20**Checkpoint%20questions**%20and%20attempt%20the%20**Problems**%20independently%3B%20their%20panels%20contain%20final%20answers%20only.%20Predict%20the%20effect%20of%20a%20parameter%20change%20before%20running%20it%2C%20and%20check%20units%20and%20limiting%20cases.%0A%0A%20%20%20%20**Opening%20challenge.**%20A%20rigid%20body%20spins%20with%20a%20constant%20angular-velocity%20vector%20in%20its%20own%20frame.%20Can%20it%20still%20need%20an%20external%20torque%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Python%20setup%0A%0A%20%20%20%20The%20dependency%20declaration%20at%20the%20top%20of%20this%20file%20lists%20the%20packages%20used%20by%20this%20guide.%20Marimo%20runs%20cells%20in%20dependency%20order.%20Run%20the%20notebook%20in%20an%20editor%20to%20use%20its%20displays%20and%20controls%3B%20the%20computational%20examples%20below%20explain%20their%20inputs%20before%20using%20them.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20The%20Newton-Euler%20laws%0A%0A%20%20%20%20The%20Newton-Euler%20laws%20remain%20valid%20in%20the%20three-dimensional%20motion%20of%20a%20rigid%20body%20(for%20revision%20on%20Newton-Euler%20laws%2C%20%5Bsee%20this%20notebook%20about%20these%20laws%5D(https%3A%2F%2Fmolab.marimo.io%2Fgithub%2FBMClab%2FBMC%2Fblob%2Fmaster%2Fnotebooks%2Fnewton_euler_equations.py)).%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BF%7D%20%3D%20m%5Cvec%7Ba_%7Bcm%7D%7D%24%24%5Cvec%7BM_O%7D%20%3D%20%5Cfrac%7Bd%5Cvec%7BH_O%7D%7D%7Bdt%7D%24%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Resultant%20force%20and%20moments%0A%0A%20%20%20%20The%20resultant%20force%20and%20the%20resultant%20moment%20around%20a%20point%20O%20are%20computed%20in%20the%20same%20way%20of%20the%20two-dimensional%20case.%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BF%7D%20%3D%20%5Csum%5Climits_%7Bi%3D1%7D%5En%20%5Cvec%7BF_n%7D%24%24%5Cvec%7BM_O%7D%20%3D%20%5Csum%5Climits_%7Bi%3D1%7D%5En%20%5Cvec%7Br_%7Bi%2FO%7D%7D%20%5Ctimes%20%5Cvec%7BF_i%7D%24%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Deduction%20of%20the%20angular%20momentum%20in%20three-dimensional%20movement%0A%0A%20%20%20%20The%20major%20difference%20that%20appears%20when%20we%20are%20dealing%20with%20three-dimensional%20motions%20is%20to%20compute%20the%20derivative%20of%20the%20angular%20momentum.%20For%20the%20sake%20of%20simplicity%2C%20the%20analysis%20will%20only%20consider%20the%20point%20O%20as%20the%20center%20of%20mass%20of%20the%20body.%0A%0A%20%20%20%20We%20begin%20computing%20the%20angular%20momentum%20of%20a%20rigid%20body%20around%20its%20center%20of%20mass.%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BH_%7Bcm%7D%7D%20%3D%20%20%5Cint_B%20%5Cvec%7Br_%7B%2Fcm%7D%7D%20%5Ctimes%20%5Cvec%7Bv%7D%5C%2Cdm%20%3D%20%5Cint%20%20%5Cvec%7Br_%7B%2Fcm%7D%7D%20%5Ctimes%20(%5Cvec%7B%5Comega%7D%5Ctimes%5Cvec%7Br_%7B%2Fcm%7D%7D)%5C%2Cdm%24%3C%2Fspan%3E%0A%20%20%20%20where%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7B%5Cboldsymbol%7Br_%7B%2Fcm%7D%7D%7D%24%3C%2Fspan%3E%20is%20the%20vector%20from%20the%20point%20O%20to%20the%20position%20of%20the%20infinitesimal%20mass%20considered%20in%20the%20integral.%20For%20simplicity%20of%20the%20notation%2C%20we%20will%20use%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7B%5Cboldsymbol%7Br%7D%7D%20%3D%20%5Cvec%7B%5Cboldsymbol%7Br_%7B%2Fcm%7D%7D%7D%24%3C%2Fspan%3E.%20The%20triple%20vector%20product%20above%20can%20be%20computed%20using%20the%20rule%3A%0A%20%20%20%20%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7Ba%7D%5Ctimes(%5Cvec%7Bb%7D%5Ctimes%5Cvec%7Bc%7D)%20%3D%20(%5Cvec%7Ba%7D.%5Cvec%7Bc%7D)%5Cvec%7Bb%7D%20-%20(%5Cvec%7Ba%7D.%5Cvec%7Bb%7D)%5Cvec%7Bc%7D%24.%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20So%2C%20the%20angular%20momentum%20is%3A%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BH_%7Bcm%7D%7D%20%3D%20%5Cint%20%20%5Cvec%7Br%7D%20%5Ctimes%20(%5Cvec%7B%5Comega%7D%5Ctimes%5Cvec%7Br%7D)%5C%2Cdm%20%3D%0A%20%20%20%20%20%20%20%20%20%20%5Cint%20%20(r_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20r_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2Br_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D)%20%5Ctimes%20%5Cleft%5B(%5Comega_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20%5Comega_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2B%5Comega_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D)%5Ctimes(r_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20r_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2Br_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D)%5Cright%5D%5C%2Cdm%20%3D%20%5Cint%20%5Cleft%5B(r_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20r_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2Br_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D).(r_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20r_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2Br_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D)%5Cright%5D(%5Comega_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20%5Comega_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2B%5Comega_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D)%20-%5Cleft%5B(r_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20r_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2Br_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D).(%5Comega_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20%5Comega_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2B%5Comega_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D)%5Cright%5D(r_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20r_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2Br_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D)%20%5C%2Cdm%20%3D%20%5Cint%20(r_x%5E2%20%2B%20r_y%5E2%2Br_z%5E2)(%5Comega_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20%5Comega_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2B%5Comega_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D)%20-%20(r_x%5Comega_x%20%2B%20r_y%5Comega_y%2Br_z%5Comega_z)(r_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20r_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2Br_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D)%5C%2Cdm%24%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BH_%7Bcm%7D%7D%20%3D%20%5Cint%20(r_x%5E2%20%2B%20r_y%5E2%2Br_z%5E2)%5Comega_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20-%20(r_x%5Comega_x%20%2B%20r_y%5Comega_y%2Br_z%5Comega_z)r_x%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20(r_x%5E2%20%2B%20r_y%5E2%2Br_z%5E2)%5Comega_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%20-%20(r_x%5Comega_x%20%2B%20r_y%5Comega_y%2Br_z%5Comega_z)r_y%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2B(r_x%5E2%20%2B%20r_y%5E2%2Br_z%5E2)%5Comega_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D%20-%20(r_x%5Comega_x%20%2B%20r_y%5Comega_y%2Br_z%5Comega_z)r_z%5Chat%7B%5Cboldsymbol%7Bk%7D%7D%5C%2Cdm%24%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BH_%7Bcm%7D%7D%3D%5Cleft(%5Cint%20%5Comega_x(r_y%5E2%2Br_z%5E2)%5C%2Cdm%2B%20%20%5Cint-%5Comega_yr_xr_y%5C%2Cdm%20%2B%20%5Cint-%5Comega_z%20r_xr_z%5C%2Cdm%5Cright)%5C%3B%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20%5Cleft(%5Cint-%5Comega_x%20r_xr_y%5C%2Cdm%20%2B%5Cint%5Comega_y%20(r_x%5E2%20%2Br_z%5E2)%5C%2Cdm%20%2B%20%5Cint-%20%5Comega_zr_yr_z%5C%2Cdm%5Cright)%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%20%2B%20%5Cleft(%5Cint-%5Comega_x%20r_xr_z%5C%2Cdm%20%20%2B%20%5Cint-%5Comega_yr_yr_z%5C%2Cdm%20%2B%20%5Cint%20%5Comega_z(r_x%5E2%2Br_y%5E2)%20%5C%2Cdm%5Cright)%5Chat%7B%5Cboldsymbol%7Bk%7D%7D%24%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BH_%7Bcm%7D%7D%3D%5Cbigg(%5Comega_x%5Cint%20(r_y%5E2%2Br_z%5E2)%5C%2Cdm%2B%20%20%5Comega_y%5Cint-r_xr_y%5C%2Cdm%20%2B%20%5Comega_z%5Cint-%20r_xr_z%5C%2Cdm%5Cbigg)%5C%3B%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%2B%5Cbigg(%5Comega_x%5Cint-%20r_xr_y%5C%2Cdm%20%2B%5Comega_y%5Cint%20(r_x%5E2%20%2Br_z%5E2)%5C%2Cdm%20%2B%20%20%5Comega_z%5Cint-r_yr_z%5C%2Cdm%5Cbigg)%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%20%2B%20%5Cbigg(%5Comega_x%5Cint-%20r_xr_z%5C%2Cdm%20%20%2B%20%5Comega_y%5Cint-r_yr_z%5C%2Cdm%20%2B%20%5Comega_z%5Cint%20(r_x%5E2%2Br_y%5E2)%20%5C%2Cdm%5Cbigg)%5Chat%7B%5Cboldsymbol%7Bk%7D%7D%24%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BH_%7Bcm%7D%7D%3D%5Cleft(%5Comega_xI_%7Bxx%7D%5E%7Bcm%7D%2B%20%20%5Comega_yI_%7Bxy%7D%5E%7Bcm%7D%20%2B%20%5Comega_zI_%7Bxz%7D%5E%7Bcm%7D%5Cright)%5C%3B%5Chat%7B%5Cboldsymbol%7Bi%7D%7D%20%2B%20%5Cleft(%5Comega_xI_%7Bxy%7D%5E%7Bcm%7D%20%2B%5Comega_yI_%7Byy%7D%5E%7Bcm%7D%20%2B%20%20%5Comega_zI_%7Byz%7D%5E%7Bcm%7D%5Cright)%5Chat%7B%5Cboldsymbol%7Bj%7D%7D%2B%5Cleft(%5Comega_xI_%7Byz%7D%5E%7Bcm%7D%20%20%2B%20%5Comega_yI_%7Byz%7D%5E%7Bcm%7D%20%2B%20%5Comega_zI_%7Bzz%7D%5E%7Bcm%7D%5Cright)%5Chat%7B%5Cboldsymbol%7Bk%7D%7D%24%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Angular%20momentum%20in%20three-dimensional%20movement%0A%0A%0A%20%20%20%20%5Cbegin%7Balign%7D%0A%20%20%20%20%5Cbegin%7Bsplit%7D%0A%20%20%20%20%20%20%20%20%20%20%5Cvec%7BH_%7Bcm%7D%7D%3D%5Cleft%5B%5Cbegin%7Barray%7D%7Bccc%7DI_%7Bxx%7D%5E%7Bcm%7D%26I_%7Bxy%7D%5E%7Bcm%7D%26I_%7Bxz%7D%5E%7Bcm%7D%5C%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20I_%7Bxy%7D%5E%7Bcm%7D%26I_%7Byy%7D%5E%7Bcm%7D%26I_%7Byz%7D%5E%7Bcm%7D%5C%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20I_%7Bxz%7D%5E%7Bcm%7D%26I_%7Byz%7D%5E%7Bcm%7D%26I_%7Bzz%7D%5E%7Bcm%7D%5Cend%7Barray%7D%5Cright%5D%5Ccdot%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7D%5Comega_x%5C%5C%5Comega_y%5C%5C%5Comega_z%20%5Cend%7Barray%7D%5Cright%5D%20%3D%20I%5Cvec%7B%5Comega%7D%0A%20%20%20%20%20%20%20%20%20%20%5Cend%7Bsplit%7D%0A%20%20%20%20%20%20%20%20%20%20%5Clabel%7Beq%3Aangmom%7D%0A%20%20%20%20%20%5Cend%7Balign%7D%0A%0A%20%20%20%20%20where%20this%20matrix%20is%20the%20Matrix%20of%20Inertia%20(or%20more%20rigorously%2C%20Tensor%20of%20Inertia)%20as%20defined%20previously%20in%20%5Bthis%20notebook%20about%20moment%20of%20inertia%5D(center_of_mass_and_moment_of_inertia.py%23matrix-of-inertia).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20**Exercise%201%20%E2%80%94%20Momentum%20need%20not%20follow%20velocity.**%20A%20body%20has%20principal%20inertia%20matrix%20%24%5Coperatorname%7Bdiag%7D(1%2C2%2C3)%24%20kg%20m%C2%B2%20and%20body%20angular%20velocity%20%24(1%2C1%2C0)%24%20rad%2Fs.%20Find%20its%20angular%20momentum.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%2F%2F%2F%20details%20%7C%20Solution%20to%20Exercise%201%0A%0A%20%20%20%20%24%5Cmathbf%20H%3D%5Cmathbf%20I%5Cboldsymbol%5Comega%3D(1%2C2%2C0)%24%20kg%20m%C2%B2%2Fs.%20It%20is%20not%20parallel%20to%20%24(1%2C1%2C0)%24%20because%20the%20first%20two%20principal%20inertias%20differ.%20Parallelism%20occurs%20along%20a%20principal%20axis%20or%20within%20a%20repeated-eigenvalue%20subspace.%0A%20%20%20%20%2F%2F%2F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20The%20matrix%20of%20inertia%20is%20different%20depending%20on%20the%20body%20orientation%0A%0A%20%20%20%20So%2C%20to%20compute%20the%20angular%20momentum%20of%20a%20body%20we%20have%20to%20multiply%20the%20matrix%20of%20inertia%20%24I%24%20of%20the%20body%20by%20its%20angular%20velocity%20%24%5Cvec%7B%5Comega%7D%24.%20The%20problem%20on%20this%20approach%20is%20that%20the%20moments%20and%20products%20of%20inertia%20depends%20on%20the%20orientation%20of%20the%20body%20relative%20to%20the%20frame%20of%20reference.%20As%20they%20depend%20on%20the%20distances%20of%20each%20point%20of%20the%20body%20to%20the%20axes%2C%20if%20the%20body%20is%20rotating%2C%20the%20matrix%20of%20inertia%20%24I%24%20will%20be%20different%20at%20each%20instant.%0A%0A%20%20%20%20%3Cfigure%3E%3Cimg%20src%3D%22https%3A%2F%2Fgithub.com%2FBMClab%2FBMC%2Fblob%2Fmaster%2Fimages%2F3Dbodyref.png%3Fraw%3D1%22%20width%3D800%20%2F%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20The%20solution%20is%20to%20attach%20a%20frame%20reference%20to%20the%20body%0A%0A%20%20%20%20The%20solution%20to%20this%20problem%20is%20to%20attach%20a%20frame%20of%20reference%20to%20the%20body.%20We%20will%20denote%20this%20frame%20of%20reference%20as%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%2C%20%24%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%24%20and%20%24%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%2C%20with%20origin%20in%20the%20center%20of%20mass%20of%20the%20body.%20As%20can%20be%20noted%20from%20the%20figure%20below%2C%20the%20frame%20of%20reference%20moves%20along%20the%20body.%20Now%20the%20matrix%20of%20inertia%20%24I%24%20will%20be%20constant%20relative%20to%20this%20new%20basis%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%2C%20%24%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%24%20and%20%24%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24.%0A%0A%20%20%20%20%3Cfigure%3E%3Cimg%20src%3D%22https%3A%2F%2Fgithub.com%2FBMClab%2FBMC%2Fblob%2Fmaster%2Fimages%2F3DbodyrefMove.png%3Fraw%3D1%22%20width%3D800%20%2F%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20The%20fixed%20frame%20is%20chosen%20in%20a%20way%20that%20the%20matrix%20of%20inertia%20is%20a%20diagonal%20matrix%0A%0A%20%20%20%20As%20we%20can%20choose%20the%20basis%20versors%20as%20we%20want%2C%20we%20can%20choose%20them%20so%20as%20to%20the%20products%20of%20inertia%20be%20equal%20to%20zero.%20This%20can%20always%20be%20done.%20If%20the%20body%20has%20axes%20of%20symmetry%2C%20%20we%20can%20choose%20these%20axes%20(principal%20axes)%20as%20the%20direction%20of%20the%20basis%20to%20the%20products%20of%20inertia%20be%20equal%20to%20zero.%20Having%20the%20basis%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%2C%20%24%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%24%20and%20%24%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%2C%20the%20matrix%20of%20inertia%20will%20be%20a%20diagonal%20matrix%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20I%20%3D%20%5Cleft%5B%5Cbegin%7Barray%7D%7Bccc%7DI_1%260%260%5C%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%200%26I_2%260%5C%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%200%260%26I_3%5Cend%7Barray%7D%5Cright%5D%0A%20%20%20%20%24%24%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20The%20angular%20velocity%20in%20the%20fixed%20frame%0A%0A%20%20%20%20So%2C%20we%20can%20write%20the%20angular%20momentum%20vector%20relative%20to%20this%20new%20basis.%20To%20do%20this%2C%20we%20must%20write%20the%20angular%20velocity%20in%20this%20new%20basis%3A%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7B%5Comega%7D%20%3D%20%5Comega_1%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20%5Comega_2%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%20%2B%20%5Comega_3%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%3C%2Fspan%3E%0A%0A%20%20%20%20Note%20that%20this%20angular%20velocity%20is%20the%20same%20vector%20that%20we%20used%20previously.%20We%20are%20just%20describing%20it%20in%20a%20basis%20attached%20to%20the%20body%20(local%20basis).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20The%20angular%20momentum%20in%20the%20fixed%20frame%0A%0A%20%20%20%20So%2C%20using%20the%20basis%20in%20the%20direction%20of%20the%20principal%20axes%20of%20the%20body%20the%20angular%20momentum%20simplifies%20to%3A%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BH_%7Bcm%7D%7D%20%3D%20I%5Cvec%7B%5Comega%7D%20%3D%20I_1%5Comega_1%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20I_2%5Comega_2%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%20%2BI_3%5Comega_3%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20**Exercise%202%20%E2%80%94%20Differentiate%20a%20rotating%20basis.**%20Use%20the%20same%20inertia%20and%20angular%20velocity%20with%20zero%20body-frame%20angular%20acceleration.%20Find%20the%20required%20body-frame%20torque.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%2F%2F%2F%20details%20%7C%20Solution%20to%20Exercise%202%0A%0A%20%20%20%20The%20transport%20theorem%20gives%20%24%5Cmathbf%20M%3D%5Cmathbf%20I%5Cdot%7B%5Cboldsymbol%5Comega%7D%2B%5Cboldsymbol%5Comega%5Ctimes(%5Cmathbf%20I%5Cboldsymbol%5Comega)%24.%20Here%20the%20first%20term%20vanishes%20and%20%24(1%2C1%2C0)%5Ctimes(1%2C2%2C0)%3D(0%2C0%2C1)%24%20N%20m.%20This%20resolves%20the%20opening%20challenge.%0A%20%20%20%20%2F%2F%2F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Derivative%20of%20the%20angular%20momentum%0A%0A%20%20%20%20For%20the%20second%20Newton-Euler%20law%2C%20we%20must%20compute%20the%20derivative%20of%20the%20angular%20momentum.%20So%2C%20we%20derive%20the%20angular%20momentum%20in%20Eq.%20%5Ceqref%7Beq%3Aangmomprinc%7D.%20As%20the%20versors%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%2C%20%24%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%24%20and%20%24%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%20are%20varying%20in%20time%2C%20we%20must%20consider%20their%20derivatives.%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cfrac%7Bd%5Cvec%7BH_%7Bcm%7D%7D%7D%7Bdt%7D%20%3D%20I_1%5Cdot%7B%5Comega_1%7D%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20I_2%5Cdot%7B%5Comega_2%7D%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%2BI_3%5Cdot%7B%5Comega_3%7D%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%2B%20I_1%5Comega_1%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%20%2B%20I_2%5Comega_2%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%7D%7Bdt%7D%2BI_3%5Comega_3%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%7D%7Bdt%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20Now%20it%20only%20remains%20to%20find%20an%20expression%20for%20the%20derivative%20of%20the%20versors%20%24%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%24%2C%20%24%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%7D%7Bdt%7D%24%20and%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%7D%7Bdt%7D%24%3Cspan%3E.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Angular%20velocity%0A%0A%0A%20%20%20%20The%20angular%20velocity%20can%20be%20written%20as%20(%5Bhere%20you%20can%20learn%20more%20about%20the%20computation%20of%20the%20angular%20velocity%5D(https%3A%2F%2Fmolab.marimo.io%2Fgithub%2FBMClab%2FBMC%2Fblob%2Fmaster%2Fnotebooks%2Fangular_velocity_3d.py))%3A%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7B%5Comega%7D%20%3D%20%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%5Cright)%0A%20%20%20%20%20%20%20%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%20%2B%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20The%20derivative%20of%20the%20versors%0A%0A%20%20%20%20Now%2C%20we%20must%20isolate%20the%20derivative%20of%20the%20versors%20to%20substitute%20them%20in%20the%20Eq.%20%5Ceqref%7Beq%3Aderivangmom%7D.%20To%20isolate%20the%20derivative%20of%20the%20versor%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%2C%20first%20we%20cross%20multiply%20both%20sides%20of%20the%20equation%20above%20by%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cvec%7B%5Comega%7D%20%5Ctimes%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%3D%20-%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%2B%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20If%20we%20note%20that%20the%20term%20multipliying%20%24%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%20in%20the%20right%20side%20of%20the%20identity%20can%20be%20obtained%20by%20%24%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%7D%7Bdt%7D%20%3D%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%2B%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%5Crightarrow%200%20%3D%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%2B%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%5Crightarrow%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%20%3D%20-%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%20(the%20scalar%20product%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%20is%20zero%20because%20these%20vectors%20are%20orthogonal)%2C%20we%20can%20write%20the%20equation%20above%20becomes%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cvec%7B%5Comega%7D%20%5Ctimes%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%3D%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%2B%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20Finally%2C%20we%20can%20note%20that%20%24%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%7D%7Bdt%7D%20%3D%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%5Crightarrow%20%5Cfrac%7Bd(1)%7D%7Bdt%7D%20%3D%202%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%5Crightarrow%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%20%3D%200%24.%20As%20this%20term%20is%20equal%20to%20zero%2C%20we%20can%20add%20it%20to%20the%20expression%20above%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%3D%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%5Cright)%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%2B%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20Note%20that%20the%20expression%20above%20is%20just%20another%20manner%20to%20write%20the%20vector%20%24%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%24%2C%20as%20any%20vector%20can%20be%20described%20by%20the%20sum%20of%20the%20projections%20on%20each%20of%20the%20versors%20forming%20a%20basis.%0A%0A%20%20%20%20So%2C%20the%20derivative%20of%20the%20versor%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%20%20can%20be%20written%20as%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%20%3D%20%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20Similarly%2C%20the%20derivatives%20of%20the%20versors%20%24%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%24%20and%20%24%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%20can%20be%20written%20as%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%7D%7Bdt%7D%20%3D%20%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%20~~~~~~~~%5Ctext%7Band%7D%20~~~~~~%20%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%7D%7Bdt%7D%20%3D%20%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%0A%20%20%20%20%24%24%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20The%20derivative%20of%20the%20angular%20momentum%0A%0A%20%20%20%20Now%20we%20can%20get%20back%20to%20the%20equation%20describing%20the%20derivative%20of%20the%20angular%20momentum%3A%0A%0A%20%20%20%20%3Ca%20id%3D%22eq%3AderivangmomVec%22%3E%3C%2Fa%3E%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cbegin%7Balign%7D%0A%20%20%20%20%20%20%20%20%5Cbegin%7Bsplit%7D%0A%20%20%20%20%20%20%20%20%5Cfrac%7Bd%5Cvec%7BH_%7Bcm%7D%7D%7D%7Bdt%7D%20%3D%26I_1%5Cdot%7B%5Comega_1%7D%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20I_2%5Cdot%7B%5Comega_2%7D%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%2BI_3%5Cdot%7B%5Comega_3%7D%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%2B%20I_1%5Comega_1%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%20%2B%20I_2%5Comega_2%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%7D%7Bdt%7D%2BI_3%5Comega_3%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%7D%7Bdt%7D%3D%5C%5C%0A%20%20%20%20%20%20%20%20%3D%26%20I_1%5Cdot%7B%5Comega_1%7D%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20I_2%5Cdot%7B%5Comega_2%7D%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%2BI_3%5Cdot%7B%5Comega_3%7D%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%2B%20I_1%5Comega_1(%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D)%20%2B%20I_2%5Comega_2(%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D)%2BI_3%5Comega_3(%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D)%20%3D%20%5C%5C%0A%20%20%20%20%20%20%20%3D%26%20I_1%5Cdot%7B%5Comega_1%7D%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20I_2%5Cdot%7B%5Comega_2%7D%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%2BI_3%5Cdot%7B%5Comega_3%7D%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%2B%20%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20I_1%5Comega_1%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20I_2%5Comega_2%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%2B%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20I_3%5Comega_3%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%3D%20%5C%5C%0A%20%20%20%20%20%20%20%3D%26%20I_1%5Cdot%7B%5Comega_1%7D%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20I_2%5Cdot%7B%5Comega_2%7D%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%2BI_3%5Cdot%7B%5Comega_3%7D%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%20%2B%20%5Cvec%7B%5Cboldsymbol%7B%5Comega%7D%7D%20%5Ctimes%20(I_1%5Comega_1%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20I_2%5Comega_2%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%20%2B%20%20I_3%5Comega_3%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D)%3D%5C%5C%0A%20%20%20%20%20%20%20%3D%26I%5Cvec%7B%5Cdot%7B%5Comega%7D%7D%20%2B%20%5Cvec%7B%5Comega%7D%20%5Ctimes%20(I%5Cvec%7B%5Comega%7D)%0A%20%20%20%20%20%20%20%5Cend%7Bsplit%7D%0A%20%20%20%20%5Cend%7Balign%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20Performing%20the%20cross%20products%2C%20we%20can%20get%20the%20expressions%20for%20each%20of%20the%20coordinates%20attached%20to%20the%20body%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cbegin%7Balign%7D%0A%20%20%20%20%20%20%20%20%5Cbegin%7Bsplit%7D%0A%20%20%20%20%20%20%20%20%5Cfrac%7Bd%5Cvec%7BH_%7Bcm%7D%7D%7D%7Bdt%7D%20%3D%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7DI_1%5Cdot%7B%5Comega_1%7D%5C%5CI_2%5Cdot%7B%5Comega_2%7D%5C%5CI_3%5Cdot%7B%5Comega_3%7D%5Cend%7Barray%7D%5Cright%5D%20%2B%20%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7D%5Comega_1%5C%5C%5Comega_2%5C%5C%5Comega_3%5Cend%7Barray%7D%5Cright%5D%20%20%5Ctimes%20%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7DI_1%5Comega_1%5C%5CI_2%5Comega_2%5C%5CI_3%5Comega_3%5Cend%7Barray%7D%5Cright%5D%20%20%3D%20%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7DI_1%5Cdot%7B%5Comega_1%7D%20%2B%20%5Comega_2%5Comega_3(I_3-I_2)%5C%5CI_2%5Cdot%7B%5Comega_2%7D%2B%5Comega_1%5Comega_3(I_1-I_3)%5C%5CI_3%5Cdot%7B%5Comega_3%7D%2B%5Comega_1%5Comega_2(I_2-I_1)%5Cend%7Barray%7D%5Cright%5D%0A%20%20%20%20%20%20%20%5Cend%7Bsplit%7D%0A%20%20%20%20%5Cend%7Balign%7D%0A%20%20%20%20%24%24%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Newton-Euler%20laws%0A%0A%20%20%20%20Having%20computed%20the%20derivative%20of%20the%20angular%20momentum%2C%20we%20have%20the%20final%20forms%20of%20the%20Newton-Euler%20laws%3A%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24F_x%20%3D%20ma_%7Bcm_x%7D%24%24F_y%20%3D%20ma_%7Bcm_y%7D%24%24F_z%20%3D%20ma_%7Bcm_z%7D%24%24M_%7Bcm_1%7D%20%3D%20I_1%5Cdot%7B%5Comega_1%7D%20%2B%20%5Comega_2%5Comega_3(I_3-I_2)%24%24M_%7Bcm_2%7D%20%3D%20I_2%5Cdot%7B%5Comega_2%7D%2B%5Comega_1%5Comega_3(I_1-I_3)%24%24M_%7Bcm_3%7D%20%3D%20I_3%5Cdot%7B%5Comega_3%7D%2B%5Comega_1%5Comega_2(I_2-I_1)%24%3C%2Fspan%3E%0A%0A%20%20%20%20Or%2C%20in%20the%20vectorial%20form%3A%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BF%7D%20%3D%20m%5Cvec%7Ba_%7Bcm%7D%7D%24%24%5Cvec%7BM_%7Bcm%7D%7D%20%3D%20I%5Cdot%7B%5Cvec%7B%5Comega%7D%7D%2B%5Cvec%7B%5Comega%7D%5Ctimes(I%5Cvec%7B%5Comega%7D)%20%5Ctext%7B%20%20%20%20%20%20%20%20%20%20%20%20(vectors%20in%20local%20frame)%7D%24%3C%2Fspan%3E%0A%0A%0A%20%20%20%20Note%20that%20the%20equations%20of%20the%20forces%20are%20written%20in%20the%20global%20frame%20of%20reference%20and%20the%20equations%20of%20the%20moments%20are%20described%20in%20the%20frame%20of%20reference%20of%20the%20body.%20So%2C%20before%20using%20Eq.~%5Ceqref%7Beq%3AderivangmomVec%7D%20or%20the%20equations%20Eq.%5Ceqref%7Beq%3AM1%7D%2C%5Ceqref%7Beq%3AM2%7D%20and%20%5Ceqref%7Beq%3AM3%7D%20you%20must%20transform%20all%20the%20forces%20and%20moment-arms%20to%20the%20frame%20of%20reference%20of%20the%20body%20by%20using%20rotation%20matrices.%0A%0A%20%20%20%20Below%20are%20shown%20some%20examples%20with%20three-dimensional%20kinematic%20data%20to%20find%20the%20forces%20and%20moments%20acting%20on%20the%20body.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20**Exercise%203%20%E2%80%94%20Rotate%20the%20inertia%20tensor.**%20A%20body%20has%20%24I_B%3D%5Coperatorname%7Bdiag%7D(1%2C2%2C3)%24%20kg%20m%C2%B2.%20A%2090%C2%B0%20rotation%20about%20z%20maps%20body%20components%20to%20laboratory%20components.%20What%20is%20%24I_G%24%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%2F%2F%2F%20details%20%7C%20Solution%20to%20Exercise%203%0A%0A%20%20%20%20With%20%24%5Cmathbf%20v_G%3DR%5Cmathbf%20v_B%24%2C%20the%20tensor%20is%20%24I_G%3DRI_BR%5ET%3D%5Coperatorname%7Bdiag%7D(2%2C1%2C3)%24%20kg%20m%C2%B2.%20Both%20sides%20of%20the%20tensor%20transform%3B%20multiplying%20on%20only%20one%20side%20is%20not%20a%20change%20of%20basis.%0A%20%20%20%20%2F%2F%2F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Examples%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20%203D%20pendulum%20bar%0A%0A%20%20%20%20%20At%20the%20file%20'..%2Fdata%2F3Dpendulum.txt'%20there%20are%203%20seconds%20of%20data%20of%203%20points%20of%20the%20three-dimensional%20cylindrical%20pendulum%2C%20very%20similar%20to%20the%20pendulum%20shown%20in%20the%20%5Bnotebook%20about%20free-body%20diagrams%5D(free_body_diagram_for_rigid_bodies.py%23pendulum)%2C%20except%20that%20it%20can%20move%20in%20every%20direction.%20Also%20it%20has%20a%20motor%20at%20the%20upper%20part%20of%20the%20cylindrical%20bar%20producing%20torques%20to%20move%20the%20bar.%20It%20has%20mass%20%24m%3D1%24%20kg%2C%20length%20%24l%3D1%24%20m%20and%20radius%20%24r%3D0.1%24%20m.%0A%0A%20%20%20%20%20The%20point%20m1%20is%20at%20the%20upper%20part%20of%20the%20cylinder%20and%20is%20the%20origin%20of%20the%20system.%0A%0A%20%20%20%20%20The%20point%20m2%20is%20at%20the%20center%20of%20mass%20of%20the%20cylinder.%0A%0A%20%20%20%20%20The%20point%20m3%20is%20a%20point%20at%20the%20surface%20of%20the%20cylinder.%0A%0A%20%20%20%20The%20free-body%20diagram%20of%20the%203d%20pendulum%20is%20depicted%20below.%20There%20is%20the%20gravitational%20force%20acting%20at%20the%20center%20of%20mass%20of%20gravity%20of%20the%20body%20and%20the%20torque%20%24%5Cvec%7BM_1%7D%24%20due%20to%20the%20motor%20acting%20on%20the%20pendulum%20and%20the%20force%20%24%5Cvec%7BF_1%7D%24%20due%20to%20the%20restraint%20at%20the%20upper%20part%20of%20the%20cylinder.%20Together%20with%20the%20forces%2C%20the%20local%20basis%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%2C%20%24%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%24%20and%20%24%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%20in%20the%20direction%20of%20the%20principal%20axes%20an%20origin%20at%20the%20center%20of%20mass%20of%20the%20body%20is%20also%20shown.%0A%0A%20%20%20%20%3Cfigure%3E%3Cimg%20src%3D%22https%3A%2F%2Fgithub.com%2FBMClab%2FBMC%2Fblob%2Fmaster%2Fimages%2F3DpendulumFBD.png%3Fraw%3D1%22%20width%3D400%20%2F%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20The%20resultant%20forces%20acting%20on%20the%20cylinder%20is%3A%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BF%7D%20%3D%20%5Cvec%7BF_O%7D%20-%20mg%5Chat%7B%5Cboldsymbol%7Bk%7D%7D%24%3C%2Fspan%3E%0A%0A%20%20%20%20So%2C%20the%20first%20Newton-Euler%20law%2C%20at%20each%20component%20of%20the%20global%20%20basis%2C%20is%20written%20as%3A%0A%0A%20%20%20%20%3Ca%20id%3D%22eq%3Afnependulum%22%3E%3C%2Fa%3E%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cbegin%7Balign%7D%0A%20%20%20%20%20%20%20%20%5Cbegin%7Baligned%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20F_%7BO_x%7D%20%26%3D%20%20ma_%7Bcm_x%7D%20%26%5Crightarrow%20%20F_%7BO_x%7D%20%26%3D%20%20ma_%7Bcm_x%7D%20%5C%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20F_%7BO_y%7D%20%26%3D%20ma_%7Bcm_y%7D%20%26%5Crightarrow%20%20F_%7BO_y%7D%20%26%3D%20%20ma_%7Bcm_y%7D%5C%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20F_%7BO_z%7D%20-%20mg%20%26%3D%20ma_%7Bcm_z%7D%20%26%5Crightarrow%20%20F_%7BO_z%7D%20%26%3D%20%20ma_%7Bcm_z%7D%20%2B%20mg%0A%20%20%20%20%20%20%20%20%5Cend%7Baligned%7D%0A%20%20%20%20%5Cend%7Balign%7D%0A%20%20%20%20%24%24%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Now%2C%20the%20resultant%20moment%20applied%20to%20the%20body%2C%20computed%20relative%20to%20the%20center%20of%20mass%2C%20is%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cvec%7BM%7D%20%3D%20%5Cvec%7BM_O%7D%20%2B%20%5Cvec%7Br_%7BO%2Fcm%7D%7D%20%5Ctimes%20%5Cvec%7BF_O%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20So%2C%20the%20second%20Newton-Euler%20law%2C%20at%20each%20of%20the%20components%20at%20the%20local%20basis%20of%20the%20body%2C%20is%20written%20as%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cbegin%7Baligned%7D%0A%20%20%20%20%5Cbegin%7Bsplit%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20M_%7BO_1%7D%20%2B%20MFocm_1%20%26%3D%20I_1%5Cdot%7B%5Comega_1%7D%20%2B%20%5Comega_2%5Comega_3(I_3-I_2)%20%5Crightarrow%20M_%7BO_1%7D%20%26%3D%20I_1%5Cdot%7B%5Comega_1%7D%20%2B%20%5Comega_2%5Comega_3(I_3-I_2)%20-%20%20MFocm_1%5C%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20M_%7BO_2%7D%20%2B%20MFocm_2%20%26%3D%20I_2%5Cdot%7B%5Comega_2%7D%20%2B%20%5Comega_1%5Comega_3(I_1-I_3)%20%5Crightarrow%20M_%7BO_2%7D%20%26%3D%20I_2%5Cdot%7B%5Comega_2%7D%20%2B%20%5Comega_1%5Comega_3(I_1-I_3)%20-%20%20MFocm_2%5C%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20M_%7BO_3%7D%20%2B%20MFocm_3%20%26%3D%20I_3%5Cdot%7B%5Comega_3%7D%20%2B%20%5Comega_1%5Comega_2(I_2-I_1)%20%5Crightarrow%20M_%7BO_3%7D%20%26%3D%20I_3%5Cdot%7B%5Comega_3%7D%20%2B%20%5Comega_1%5Comega_2(I_2-I_1)%20-%20%20MFocm_3%0A%20%20%20%20%20%20%20%20%5Cend%7Bsplit%7D%0A%20%20%20%20%5Cend%7Baligned%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%0A%0A%20%20%20%20where%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7BMFocm%7D%20%3D%20%5Cvec%7Br_%7BO%2Fcm%7D%7D%20%5Ctimes%20%5Cvec%7BF_O%7D%24.%0A%0A%20%20%20%20The%20moments%20of%20inertia%20at%20the%20directions%20of%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%2C%20%24%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%24%20and%20%24%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%20are%2C%20%24I_1%20%3D%20%5Cfrac%7BmR%5E2%7D%7B12%7D%24%20and%20%24I_2%3DI_3%3D%5Cfrac%7Bm(3R%5E2%2Bl%5E2)%7D%7B12%7D%24.%20Now%2C%20to%20compute%20the%20moment%20%24%5Cvec%7BM_O%7D%24%20and%20the%20force%20%20%24%5Cvec%7BF_O%7D%24%2C%20we%20will%20need%20to%20find%20the%20acceleration%20of%20the%20center%20of%20mass%20%24%5Cvec%7Ba_%7Bcm%7D%7D%24%2C%20the%20angular%20velocity%20%20%24%5Cvec%7B%5Comega%7D%24%2C%20the%20time-derivatives%20of%20each%20component%20of%20the%20angular%20velocity%2C%20and%20the%20moment-arm%20%24%5Cvec%7Br_%7BO%2Fcm%7D%7D%24%20to%20compute%20the%20torque%20due%20to%20the%20force%20%24%5Cvec%7BF_O%7D%24.%20These%20signals%20will%20come%20from%20the%20kinematic%20data%20file.%0A%0A%20%20%20%20First%2C%20%20we%20need%20to%20open%20the%20file%20with%20the%20data%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20from%20notebook_resources%20import%20repo_file%0A%20%20%20%20except%20ModuleNotFoundError%20as%20_error%3A%0A%20%20%20%20%20%20%20%20if%20_error.name%20!%3D%20%22notebook_resources%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20raise%0A%20%20%20%20%20%20%20%20raise%20ModuleNotFoundError(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22This%20notebook%20needs%20notebook_resources.py.%20Download%20it%20from%3A%5Cn%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%22https%3A%2F%2Fraw.githubusercontent.com%2FBMClab%2FBMC%2Fmaster%2Ffunctions%2Fnotebook_resources.py%5Cn%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Save%20it%20in%20the%20same%20folder%20as%20this%20notebook%2C%20then%20rerun%20this%20cell.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3D%22notebook_resources%22%2C%0A%20%20%20%20%20%20%20%20)%20from%20None%0A%20%20%20%20return%20(repo_file%2C)%0A%0A%0A%40app.cell%0Adef%20_(repo_file)%3A%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%0A%20%20%20%20np.set_printoptions(precision%3D2)%0A%20%20%20%20f%20%3D%20open(repo_file('data%2F3dPendulum.txt'))%0A%20%20%20%20data%20%3D%20np.loadtxt(repo_file('data%2F3dPendulum.txt')%2C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20skiprows%3D1%2C%20delimiter%20%3D%20'%2C')%0A%20%20%20%20header%20%3D%20f.readline()%0A%20%20%20%20print(header)%0A%20%20%20%20print(data)%0A%20%20%20%20return%20data%2C%20np%2C%20plt%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20m%20%3D%201%0A%20%20%20%20g%20%3D%209.81%0A%20%20%20%20l%20%3D%201%0A%20%20%20%20_r%20%3D%200.1%0A%20%20%20%20I1%20%3D%20m%20*%20_r%20**%202%20%2F%2012%0A%20%20%20%20I2%20%3D%20m%20*%20(3%20*%20_r%20**%202%20%2B%20l%20**%202)%20%2F%2012%0A%20%20%20%20I3%20%3D%20I2%0A%20%20%20%20return%20I1%2C%20I2%2C%20I3%2C%20g%2C%20m%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Now%2C%20we%20assign%20the%20proper%20columns%20to%20variables%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(data)%3A%0A%20%20%20%20t%20%3D%20data%5B%3A%2C0%5D%0A%20%20%20%20m1%20%3D%20data%5B%3A%2C1%3A4%5D%0A%20%20%20%20m2%20%3D%20data%5B%3A%2C4%3A7%5D%0A%20%20%20%20m3%20%3D%20data%5B%3A%2C7%3A%5D%0A%20%20%20%20return%20m1%2C%20m2%2C%20m3%2C%20t%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20As%20the%20center%20of%20mass%20is%20the%20data%20contained%20in%20m2%2C%20we%20can%20find%20the%20acceleration%20of%20the%20center%20of%20mass%20%24%5Cvec%7B%5Cboldsymbol%7Ba_%7Bcm%7D%7D%7D%24.%20This%20will%20be%20performed%20by%20deriving%20numerically%20the%20position%20of%20the%20center%20of%20mass%20twice.%20The%20numerical%20derivative%20of%20a%20function%20%24f(t)%24%20with%20the%20samples%20%24f(i)%24%20can%20be%20performed%20by%20taking%20the%20forward%20difference%20of%20the%20values%20%24f(i)%24%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cfrac%7Bdf%7D%7Bdt%7D(i)%20%3D%20%5Cfrac%7Bf(i%2B1)-f(i)%7D%7B%5CDelta%20t%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20The%20numerical%20derivative%20could%20be%20obtained%20by%20taking%20the%20backward%20differences%20as%20well%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cfrac%7Bdf%7D%7Bdt%7D(i)%20%3D%20%5Cfrac%7Bf(i)-f(i-1)%7D%7B%5CDelta%20t%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20A%20better%20estimation%20of%20the%20derivative%20of%20the%20time%20derivative%20of%20the%20function%20%24f(t)%24%20would%20be%20obtained%20by%20the%20average%20value%20between%20the%20estimations%20using%20the%20backward%20and%20forward%20differences%20(this%20subject%20is%20treated%20%5Bin%20this%20notebook%20about%20data%20filtering%5D(data_filtering.py%23kinematics-of-a-ball-toss))%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cfrac%7Bdf%7D%7Bdt%7D(i)%20%3D%20%5Cfrac%7B%5Cfrac%7Bf(i%2B1)-f(i)%7D%7B%5CDelta%20t%7D%20%2B%20%5Cfrac%7Bf(i)-f(i-1)%7D%7B%5CDelta%20t%7D%7D%7B2%7D%20%3D%20%5Cfrac%7Bf(i%2B1)-f(i-1)%7D%7B2%5CDelta%20t%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20So%2C%20the%20acceleration%20of%20the%20center%20of%20mass%2C%20is%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(m2%2C%20t)%3A%0A%20%20%20%20dt%20%3D%20t%5B1%5D%20-%20t%5B0%5D%0A%20%20%20%20rcm%20%3D%20m2%0A%20%20%20%20_vcm%20%3D%20(rcm%5B2%3A%2C%20%3A%5D%20-%20rcm%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt)%0A%20%20%20%20acm%20%3D%20(_vcm%5B2%3A%2C%20%3A%5D%20-%20_vcm%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt)%0A%20%20%20%20print(rcm.shape)%0A%20%20%20%20print(acm.shape)%0A%20%20%20%20return%20acm%2C%20dt%2C%20rcm%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Now%20we%20can%20find%20the%20force%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7B%5Cboldsymbol%7BF_O%7D%7D%24%3C%2Fspan%3E%20%20using%20the%20Eq.%20%5Ceqref%7Beq%3Afnependulum%7D.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(acm%2C%20g%2C%20m%2C%20np%2C%20plt%2C%20t)%3A%0A%20%20%20%20Fox%20%3D%20m*acm%5B%3A%2C0%5D%0A%20%20%20%20Foy%20%3D%20m*acm%5B%3A%2C1%5D%0A%20%20%20%20Foz%20%3D%20m*acm%5B%3A%2C2%5D%20%2B%20m*g%0A%20%20%20%20Fo%3Dnp.hstack((Fox.reshape(-1%2C1)%2CFoy.reshape(-1%2C1)%2CFoz.reshape(-1%2C1)))%0A%0A%20%20%20%20plt.figure()%0A%20%20%20%20plt.plot(t%5B0%3Aacm.shape%5B0%5D%5D%2C%20Fox)%0A%20%20%20%20plt.plot(t%5B0%3Aacm.shape%5B0%5D%5D%2C%20Foy%2C%20'--')%0A%20%20%20%20plt.plot(t%5B0%3Aacm.shape%5B0%5D%5D%2C%20Foz)%0A%20%20%20%20plt.legend(('x'%2C'y'%2C'z'))%0A%20%20%20%20plt.title('Force%20(N)')%0A%20%20%20%20plt.show()%0A%20%20%20%20return%20(Fo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Now%2C%20to%20find%20the%20moment%20being%20applied%20to%20the%20body%2C%20we%20need%20to%20compute%20a%20basis%20attached%20to%20the%20body%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(m1%2C%20m2%2C%20m3%2C%20np)%3A%0A%20%20%20%20e1%20%3D%20m2%20-%20m1%0A%20%20%20%20e1%20%3D%20e1%2Fnp.linalg.norm(e1%2Caxis%3D1%2Ckeepdims%3DTrue)%0A%0A%20%20%20%20e2_temp%20%3D%20m3-m2%0A%20%20%20%20e2_temp%20%3D%20e2_temp%2Fnp.linalg.norm(e2_temp%2Caxis%3D1%2Ckeepdims%3DTrue)%0A%0A%20%20%20%20e3%20%3D%20np.cross(e1%2Ce2_temp%2Caxis%3D1)%0A%20%20%20%20e3%20%3D%20e3%2Fnp.linalg.norm(e3%2Caxis%3D1%2Ckeepdims%3DTrue)%0A%0A%20%20%20%20e2%20%3D%20np.cross(e3%2Ce1%2C%20axis%3D1)%0A%20%20%20%20e2%20%3D%20e2%2Fnp.linalg.norm(e2%2Caxis%3D1%2Ckeepdims%3DTrue)%0A%20%20%20%20return%20e1%2C%20e2%2C%20e3%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20To%20compute%20the%20moment%20applied%20to%20the%20body%2C%20we%20need%20the%20angular%20velocity%20described%20in%20the%20basis%20attached%20to%20the%20body.%20The%20easiest%20way%20to%20find%20this%20angular%20velocity%20is%20to%20use%20Eq.%20%5Ceqref%7Beq%3Aangvel%7D%2C%20repeated%20here.%0A%0A%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7B%5Comega%7D%20%3D%20%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%20%2B%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%20%2B%20%5Cleft(%5Cfrac%7Bd%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%7D%7Bdt%7D%5Ccdot%20%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%5Cright)%20%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%3C%2Fspan%3E%0A%0A%0A%20%20%20%20%20To%20do%20this%20we%20need%20the%20derivatives%20of%20the%20basis%20versors.%20This%20will%20also%20be%20performed%20with%20Eq.%20%5Ceqref%7Beq%3Acentralderiv%7D.%0A%0A%20%20%20%20%20To%20perform%20the%20computation%20of%20the%20angular%20velocity%20remember%20that%20the%20scalar%20product%20between%20two%20vectors%20is%20given%20by%3A%0A%0A%20%20%20%20%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7Bv%7D%5Ccdot%5Cvec%7Bw%7D%20%3D%20%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7Dv_x%5C%5Cv_y%5C%5Cv_z%20%5Cend%7Barray%7D%5Cright%5D%5Ccdot%20%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7Dw_x%5C%5Cw_y%5C%5Cw_z%20%5Cend%7Barray%7D%5Cright%5D%20%3D%20%20v_x.w_x%2Bv_yw_y%2Bv_zw_z%24%3C%2Fspan%3E%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(dt%2C%20e1%2C%20e2%2C%20e3%2C%20np)%3A%0A%20%20%20%20_de1dt%20%3D%20(e1%5B2%3A%2C%20%3A%5D%20-%20e1%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt)%0A%20%20%20%20_de2dt%20%3D%20(e2%5B2%3A%2C%20%3A%5D%20-%20e2%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt)%0A%20%20%20%20_de3dt%20%3D%20(e3%5B2%3A%2C%20%3A%5D%20-%20e3%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt)%0A%20%20%20%20omega%20%3D%20np.hstack((np.sum(_de2dt%20*%20e3%5B1%3A-1%2C%20%3A%5D%2C%20axis%3D1%2C%20keepdims%3DTrue)%2C%20np.sum(_de3dt%20*%20e1%5B1%3A-1%2C%20%3A%5D%2C%20axis%3D1%2C%20keepdims%3DTrue)%2C%20np.sum(_de1dt%20*%20e2%5B1%3A-1%2C%20%3A%5D%2C%20axis%3D1%2C%20keepdims%3DTrue)))%0A%20%20%20%20return%20(omega%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20From%20the%20angular%20velocity%20vector%20we%20can%20obtain%20the%20derivatives%20of%20each%20component%20of%20it%2C%20also%20needed%20to%20compute%20the%20moment%20applied%20to%20the%20body.%20To%20do%20this%20we%20will%20use%20Eq.%20%5Ceqref%7Beq%3Acentralderiv%7D%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(dt%2C%20omega)%3A%0A%20%20%20%20alpha%20%3D%20(omega%5B2%3A%2C%3A%5D-omega%5B0%3A-2%2C%3A%5D)%2F(2*dt)%0A%20%20%20%20return%20(alpha%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20It%20remains%20to%20find%20the%20moment%20caused%20by%20the%20force%20%24%5Cvec%7BF_O%7D%24%2C%20%24%5Cvec%7BMFocm%7D%20%3D%20%5Cvec%7Br_%7BO%2Fcm%7D%7D%20%5Ctimes%20%5Cvec%7BF_O%7D%24.%20The%20moment-arm%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7Br_%7BO%2Fcm%7D%7D%20%3D-%5Cvec%7Br_%7Bcm%7D%7D%24.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(Fo%2C%20np%2C%20rcm)%3A%0A%20%20%20%20MFocm%20%3D%20np.cross(-rcm%5B2%3A-2%5D%2C%20Fo)%0A%20%20%20%20return%20(MFocm%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20The%20problem%20is%20that%20this%20moment%20is%20in%20the%20global%20basis.%20We%20need%20to%20transform%20it%20to%20the%20local%20basis.%20This%20will%20be%20performed%20using%20the%20rotation%20matrix%20of%20the%20bar.%20Each%20row%20of%20this%20matrix%20is%20one%20of%20the%20basis%20versors.%20Note%20that%20at%20each%20instant%20the%20matrix%20of%20rotation%20%24R%24%20will%20be%20different.%20%20After%20the%20matrix%20is%20formed%2C%20we%20can%20find%20the%20components%20of%20the%20moment%20%24%5Cvec%7BMFocm%7D%24%20in%20the%20local%20basis%20by%20multiplying%20the%20matrix%20of%20rotation%20%24R%24%20by%20the%20vector%20%24%5Cvec%7BMFocm%7D%24.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(MFocm%2C%20e1%2C%20e2%2C%20e3%2C%20np)%3A%0A%20%20%20%20MFocmLocal%20%3D%20np.zeros_like(MFocm)%0A%20%20%20%20for%20_i%20in%20range(MFocm.shape%5B0%5D)%3A%0A%20%20%20%20%20%20%20%20_R%20%3D%20np.vstack((e1%5B_i%2C%20%3A%5D%2C%20e2%5B_i%2C%20%3A%5D%2C%20e3%5B_i%2C%20%3A%5D))%0A%20%20%20%20%20%20%20%20MFocmLocal%5B_i%2C%20%3A%5D%20%3D%20_R%20%40%20MFocm%5B_i%2C%20%3A%5D%0A%20%20%20%20return%20(MFocmLocal%2C)%0A%0A%0A%40app.cell%0Adef%20_(I1%2C%20I2%2C%20I3%2C%20MFocmLocal%2C%20alpha%2C%20omega%2C%20plt%2C%20t)%3A%0A%20%20%20%20Mo1%20%3D%20I1*alpha%5B%3A%2C0%5D%20%2B%20omega%5B0%3Aalpha.shape%5B0%5D%2C1%5D*omega%5B0%3Aalpha.shape%5B0%5D%2C2%5D*(I3-I2)%20-%20MFocmLocal%5B%3A%2C0%5D%0A%20%20%20%20Mo2%20%3D%20I2*alpha%5B%3A%2C1%5D%20%2B%20omega%5B0%3Aalpha.shape%5B0%5D%2C0%5D*omega%5B0%3Aalpha.shape%5B0%5D%2C2%5D*(I1-I3)%20-%20MFocmLocal%5B%3A%2C1%5D%0A%20%20%20%20Mo3%20%3D%20I3*alpha%5B%3A%2C2%5D%20%2B%20omega%5B0%3Aalpha.shape%5B0%5D%2C0%5D*omega%5B0%3Aalpha.shape%5B0%5D%2C1%5D*(I2-I1)%20-%20MFocmLocal%5B%3A%2C2%5D%0A%20%20%20%20plt.figure()%0A%20%20%20%20plt.plot(t%5B2%3A-2%5D%2C%20Mo1)%0A%20%20%20%20plt.plot(t%5B2%3A-2%5D%2C%20Mo2)%0A%20%20%20%20plt.plot(t%5B2%3A-2%5D%2C%20Mo3)%0A%20%20%20%20plt.legend(('%24e_1%24'%2C'%24e_2%24'%2C'%24e_3%24'))%0A%20%20%20%20plt.show()%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20We%20could%20also%20have%20used%20the%20vectorial%20form%20of%20the%20derivative%20of%20the%20angular%20momentum%20(Eq.%20%5Ceqref%7Beq%3AderivangmomVec%7D)%20and%20instead%20of%20writing%20three%20lines%20of%20code%2C%20write%20only%20one.%20The%20result%20is%20the%20same.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(I1%2C%20I2%2C%20I3%2C%20MFocmLocal%2C%20alpha%2C%20np%2C%20omega%2C%20plt%2C%20t)%3A%0A%20%20%20%20_I%20%3D%20np.array(%5B%5BI1%2C%200%2C%200%5D%2C%20%5B0%2C%20I2%2C%200%5D%2C%20%5B0%2C%200%2C%20I3%5D%5D)%0A%20%20%20%20Mo%20%3D%20(_I%20%40%20alpha.T).T%20%2B%20np.cross(omega%5B0%3Aalpha.shape%5B0%5D%2C%20%3A%5D%2C%20(_I%20%40%20omega%5B0%3Aalpha.shape%5B0%5D%2C%20%3A%5D.T).T%2C%20axis%3D1)%20-%20MFocmLocal%0A%20%20%20%20plt.figure()%0A%20%20%20%20plt.plot(t%5B2%3A-2%5D%2C%20Mo)%0A%20%20%20%20plt.legend(('%24e_1%24'%2C%20'%24e_2%24'%2C%20'%24e_3%24'))%0A%20%20%20%20plt.show()%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20**Exercise%204%20%E2%80%94%20Choose%20a%20derivative%20strategy.**%20Why%20can%20angular%20acceleration%20computed%20from%20marker%20data%20be%20much%20noisier%20than%20angular%20velocity%2C%20even%20with%20an%20exact%20differentiation%20formula%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%2F%2F%2F%20details%20%7C%20Solution%20to%20Exercise%204%0A%0A%20%20%20%20Differentiation%20amplifies%20high-frequency%20measurement%20noise.%20A%20second%20derivative%20amplifies%20it%20more%20strongly.%20Inspect%20sampling%2C%20coordinate%20continuity%20and%20filtering%20before%20differentiating%2C%20then%20report%20the%20filter%20and%20assess%20sensitivity%20rather%20than%20interpreting%20every%20spike%20as%20a%20physical%20torque.%0A%20%20%20%20%2F%2F%2F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Data%20from%20postural%20control%0A%0A%20%20%20%20This%20example%20will%20use%20real%20data%20from%20a%20subject%20during%20quiet%20standing%20during%2060%20seconds.%20This%20data%20is%20from%20the%20database%20freely%20available%20at%20%5Bhttps%3A%2F%2Fgithub.com%2Fdemotu%2Fdatasets%2Ftree%2Fmaster%2FPDS%5D(https%3A%2F%2Fgithub.com%2Fdemotu%2Fdatasets%2Ftree%2Fmaster%2FPDS).%20The%20data%20of%20this%20subject%20is%20in%20the%20file%20'..%2Fdata%2FpostureData.txt'.%0A%0A%20%20%20%20The%20mass%20of%20the%20subject%20was%20%24m%20%3D%2053%24%20kg%20and%20her%20height%20was%20%24h%3D%201.65%24%20m.%0A%0A%20%20%20%20%20%20%20The%20free-body%20diagram%20is%20very%20similar%20to%20the%20free-body%20diagram%20shown%20%5Bin%20the%20notebook%20about%20free-body%20diagram%5D(free_body_diagram_for_rigid_bodies.py%23human-quiet-standing)%2C%20except%20that%20the%20force%20%24%5Cvec%7BF_A%7D%24%20and%20the%20moment%20%24%5Cvec%7BM_A%7D%24%20have%20components%20at%20all%203%20directions.%0A%0A%20%20%20%20%20%20%20So%2C%20the%20first%20Newton-Euler%20law%2C%20at%20each%20component%20of%20the%20global%20%20basis%2C%20is%20written%20as%20(note%20that%20in%20these%20data%2C%20the%20vertical%20direction%20is%20the%20y%20coordinate)%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cbegin%7Baligned%7D%0A%20%20%20%20%5Cbegin%7Bsplit%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20F_%7BA_x%7D%20%26%3D%20%20ma_%7Bcm_x%7D%20%26%5Crightarrow%20%20F_%7BA_x%7D%20%26%3D%20%20ma_%7Bcm_x%7D%20%5C%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20F_%7BA_y%7D%20%20-%20mg%20%26%3D%20ma_%7Bcm_y%7D%20%26%5Crightarrow%20%20F_%7BA_y%7D%20%26%3D%20%20ma_%7Bcm_y%7D%20%2B%20mg%5C%5C%0A%20%20%20%20%20%20%20%20%20%20%20%20F_%7BA_z%7D%20%26%3D%20ma_%7Bcm_z%7D%20%26%5Crightarrow%20%20F_%7BA_z%7D%20%26%3D%20%20ma_%7Bcm_z%7D%0A%20%20%20%20%20%20%20%20%5Cend%7Bsplit%7D%0A%20%20%20%20%5Cend%7Baligned%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20Now%2C%20the%20resultant%20moment%20applied%20to%20the%20body%2C%20computed%20relative%20to%20the%20center%20of%20mass%2C%20is%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cvec%7BM%7D%20%3D%20%5Cvec%7BM_A%7D%20%2B%20%5Cvec%7Br_%7BA%2Fcm%7D%7D%20%5Ctimes%20%5Cvec%7BF_A%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20So%2C%20the%20second%20Newton-Euler%20law%2C%20at%20each%20of%20the%20components%20at%20the%20local%20basis%20of%20the%20body%2C%20is%20written%20as%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cbegin%7Baligned%7D%0A%20%20%20%20%5Cbegin%7Bsplit%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%5Cvec%7BM_A%7D%20%2B%20%5Cvec%7BMFacm%7D%20%26%3D%20I%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7D%5Cdot%7B%5Comega_1%7D%5C%5C%5Cdot%7B%5Comega_2%7D%5C%5C%5Cdot%7B%5Comega_3%7D%5Cend%7Barray%7D%5Cright%5D%20%2B%20%5Cvec%7B%5Comega%7D%5Ctimes%20%20I%5Cvec%7B%5Comega%7D%20%5Crightarrow%20%5Cvec%7BM_A%7D%20%3D%20I%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7D%5Cdot%7B%5Comega_1%7D%5C%5C%5Cdot%7B%5Comega_2%7D%5C%5C%5Cdot%7B%5Comega_3%7D%5Cend%7Barray%7D%5Cright%5D%20%2B%20%5Cvec%7B%5Comega%7D%20%5Ctimes%20%20I%5Cvec%7B%5Comega%7D-%20%5Cvec%7BMFacm%7D%0A%20%20%20%20%20%20%20%20%5Cend%7Bsplit%7D%0A%20%20%20%20%5Cend%7Baligned%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20where%20%20%24%5Cvec%7BMFAcm%7D%20%3D%20%5Cvec%7Br_%7BA%2Fcm%7D%7D%20%5Ctimes%20%5Cvec%7BF_A%7D%24.%0A%0A%20%20%20%20Now%20we%20open%20the%20data%20and%20assign%20the%20coordinates%20of%20each%20marker%20to%20a%20variable.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(np%2C%20repo_file)%3A%0A%20%20%20%20data_1%20%3D%20np.loadtxt(repo_file('data%2FpostureData.txt')%2C%20skiprows%3D1%2C%20delimiter%3D'%2C')%0A%20%20%20%20t_1%20%3D%20data_1%5B%3A%2C%200%5D%0A%20%20%20%20dt_1%20%3D%20t_1%5B2%5D%20-%20t_1%5B1%5D%0A%20%20%20%20rcm_1%20%3D%20data_1%5B%3A%2C%201%3A4%5D%0A%20%20%20%20rrA%20%3D%20data_1%5B%3A%2C%204%3A7%5D%0A%20%20%20%20rlA%20%3D%20data_1%5B%3A%2C%207%3A%5D%0A%20%20%20%20return%20dt_1%2C%20rcm_1%2C%20rlA%2C%20rrA%2C%20t_1%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20The%20body%20will%20be%20approximated%20by%20a%20cylinder%20with%20the%20height%20of%20the%20subject%20and%20radius%20equal%20to%20half%20of%20the%20mean%20distances%20between%20the%20right%20and%20left%20medial%20malleoli.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(np%2C%20rlA%2C%20rrA)%3A%0A%20%20%20%20m_1%20%3D%2053%0A%20%20%20%20h%20%3D%201.65%0A%20%20%20%20_r%20%3D%20np.mean(np.linalg.norm(rrA%20-%20rlA%2C%20axis%3D1))%20%2F%202%0A%20%20%20%20I1_1%20%3D%20m_1%20*%20_r%20**%202%20%2F%2012%0A%20%20%20%20I2_1%20%3D%20m_1%20*%20(3%20*%20_r%20**%202%20%2B%20h%20**%202)%20%2F%2012%0A%20%20%20%20I3_1%20%3D%20I2_1%0A%20%20%20%20return%20I1_1%2C%20I2_1%2C%20I3_1%2C%20m_1%0A%0A%0A%40app.cell%0Adef%20_(dt_1%2C%20g%2C%20m_1%2C%20np%2C%20rcm_1)%3A%0A%20%20%20%20_vcm%20%3D%20(rcm_1%5B2%3A%2C%20%3A%5D%20-%20rcm_1%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt_1)%0A%20%20%20%20acm_1%20%3D%20(_vcm%5B2%3A%2C%20%3A%5D%20-%20_vcm%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt_1)%0A%20%20%20%20FAx%20%3D%20m_1%20*%20acm_1%5B%3A%2C%200%5D%0A%20%20%20%20FAy%20%3D%20m_1%20*%20acm_1%5B%3A%2C%201%5D%20%2B%20m_1%20*%20g%0A%20%20%20%20FAz%20%3D%20m_1%20*%20acm_1%5B%3A%2C%202%5D%0A%20%20%20%20FA%20%3D%20np.hstack((FAx.reshape(-1%2C%201)%2C%20FAy.reshape(-1%2C%201)%2C%20FAz.reshape(-1%2C%201)))%0A%20%20%20%20return%20(FA%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Now%20we%20form%20the%20basis%20attached%20to%20the%20body.%20The%20first%20versor%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%20will%20be%20a%20versor%20from%20the%20midpoint%20between%20the%20medial%20malleoli%20and%20the%20center%20of%20mass%20of%20the%20body.%20The%20second%20versor%20%24%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%24%20will%20be%20a%20versor%20from%20%20the%20right%20to%20the%20left%20malleolus.%20The%20third%20versor%20%24%5Chat%7B%5Cboldsymbol%7Be_3%7D%7D%24%20will%20be%20a%20cross%20product%20between%20%24%5Chat%7B%5Cboldsymbol%7Be_1%7D%7D%24%20and%20%24%5Chat%7B%5Cboldsymbol%7Be_2%7D%7D%24.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(np%2C%20rcm_1%2C%20rlA%2C%20rrA)%3A%0A%20%20%20%20e1_1%20%3D%20rcm_1%20-%20(rlA%20%2B%20rrA)%20%2F%202%0A%20%20%20%20e1_1%20%3D%20e1_1%20%2F%20np.linalg.norm(e1_1%2C%20axis%3D1%2C%20keepdims%3DTrue)%0A%20%20%20%20e2_1%20%3D%20rlA%20-%20rrA%0A%20%20%20%20e2_1%20%3D%20e2_1%20%2F%20np.linalg.norm(e2_1%2C%20axis%3D1%2C%20keepdims%3DTrue)%0A%20%20%20%20e3_1%20%3D%20np.cross(e1_1%2C%20e2_1%2C%20axis%3D1)%0A%20%20%20%20e3_1%20%3D%20e3_1%20%2F%20np.linalg.norm(e3_1%2C%20axis%3D1%2C%20keepdims%3DTrue)%0A%20%20%20%20e2_1%20%3D%20np.cross(e3_1%2C%20e1_1%2C%20axis%3D1)%0A%20%20%20%20e2_1%20%3D%20e2_1%20%2F%20np.linalg.norm(e2_1%2C%20axis%3D1%2C%20keepdims%3DTrue)%0A%20%20%20%20return%20e1_1%2C%20e2_1%2C%20e3_1%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Now%20we%20can%20find%20the%20angular%20velocity%20%3Cspan%20class%3D%22notranslate%22%3E%24%5Cvec%7B%5Comega%7D%24%3C%2Fspan%3E%20at%20the%20basis%20attached%20to%20the%20body%20using%20Eq.%5Ceqref%7Beq%3Aangvel%7D%20and%20the%20time%20derivatives%20of%20its%20components.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(dt_1%2C%20e1_1%2C%20e2_1%2C%20e3_1%2C%20np)%3A%0A%20%20%20%20_de1dt%20%3D%20(e1_1%5B2%3A%2C%20%3A%5D%20-%20e1_1%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt_1)%0A%20%20%20%20_de2dt%20%3D%20(e2_1%5B2%3A%2C%20%3A%5D%20-%20e2_1%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt_1)%0A%20%20%20%20_de3dt%20%3D%20(e3_1%5B2%3A%2C%20%3A%5D%20-%20e3_1%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt_1)%0A%20%20%20%20omega_1%20%3D%20np.hstack((np.sum(_de2dt%20*%20e3_1%5B1%3A-1%2C%20%3A%5D%2C%20axis%3D1).reshape(-1%2C%201)%2C%20np.sum(_de3dt%20*%20e1_1%5B1%3A-1%2C%20%3A%5D%2C%20axis%3D1).reshape(-1%2C%201)%2C%20np.sum(_de1dt%20*%20e2_1%5B1%3A-1%2C%20%3A%5D%2C%20axis%3D1).reshape(-1%2C%201)))%0A%20%20%20%20alpha_1%20%3D%20(omega_1%5B2%3A%2C%20%3A%5D%20-%20omega_1%5B0%3A-2%2C%20%3A%5D)%20%2F%20(2%20*%20dt_1)%0A%20%20%20%20return%20alpha_1%2C%20omega_1%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Now%20we%20need%20to%20find%20the%20moment%20caused%20by%20the%20force%20at%20the%20ankles%20%24%5Cvec%7BF_A%7D%24%2C%20%24%5Cvec%7BMFAcm%7D%20%3D%20%5Cvec%7Br_%7BA%2Fcm%7D%7D%20%5Ctimes%20%5Cvec%7BF_A%7D%24.%20The%20moment-arm%20%24%5Cvec%7Br_%7BA%2Fcm%7D%7D%24%20is%20the%20vector%20from%20the%20center%20of%20mass%20to%20the%20midpoint%20of%20the%20lateral%20malleoli.%0A%0A%20%20%20%20Besides%20the%20description%20of%20the%20moment%20due%20to%20the%20force%20%24%5Cvec%7BF_A%7D%24%20in%20the%20basis%20attached%20to%20the%20body%2C%20we%20will%20also%20describe%20the%20force%20%24%5Cvec%7BF_A%7D%24%20at%20the%20local%20basis.%20This%20is%20useful%20because%20it%20has%20an%20anatomical%20meaning.%20After%20this%20we%20can%20use%20the%20equations%20of%20Newton-Euler%20to%20obtain%20the%20moment%20at%20the%20ankle.%0A%0A%20%20%20%20After%20having%20all%20signals%20described%20in%20the%20basis%20of%20the%20body%2C%20the%20moment%20being%20applied%20by%20the%20muscles%20of%20the%20ankle%20is%20computed%20using%20Eq.%20%5Ceqref%7Beq%3AderivangmomVec%7D.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20FA%2C%0A%20%20%20%20I1_1%2C%0A%20%20%20%20I2_1%2C%0A%20%20%20%20I3_1%2C%0A%20%20%20%20alpha_1%2C%0A%20%20%20%20e1_1%2C%0A%20%20%20%20e2_1%2C%0A%20%20%20%20e3_1%2C%0A%20%20%20%20np%2C%0A%20%20%20%20omega_1%2C%0A%20%20%20%20plt%2C%0A%20%20%20%20rcm_1%2C%0A%20%20%20%20rlA%2C%0A%20%20%20%20rrA%2C%0A%20%20%20%20t_1%2C%0A)%3A%0A%20%20%20%20racm%20%3D%20(rlA%20%2B%20rrA)%20%2F%202%20-%20rcm_1%0A%20%20%20%20MFAcm%20%3D%20np.cross(racm%5B0%3AFA.shape%5B0%5D%2C%20%3A%5D%2C%20FA)%0A%20%20%20%20MFAcmLocal%20%3D%20np.zeros_like(MFAcm)%0A%20%20%20%20FALocal%20%3D%20np.zeros_like(MFAcm)%0A%20%20%20%20for%20_i%20in%20range(MFAcm.shape%5B0%5D)%3A%0A%20%20%20%20%20%20%20%20_R%20%3D%20np.vstack((e1_1%5B_i%2C%20%3A%5D%2C%20e2_1%5B_i%2C%20%3A%5D%2C%20e3_1%5B_i%2C%20%3A%5D))%0A%20%20%20%20%20%20%20%20MFAcmLocal%5B_i%2C%20%3A%5D%20%3D%20_R%20%40%20MFAcm%5B_i%2C%20%3A%5D%0A%20%20%20%20%20%20%20%20FALocal%5B_i%2C%20%3A%5D%20%3D%20_R%20%40%20FA%5B_i%2C%20%3A%5D%0A%20%20%20%20_I%20%3D%20np.diag(%5BI1_1%2C%20I2_1%2C%20I3_1%5D)%0A%20%20%20%20MA%20%3D%20(_I%20%40%20alpha_1.T).T%20%2B%20np.cross(omega_1%5B0%3Aalpha_1.shape%5B0%5D%2C%20%3A%5D%2C%20(_I%20%40%20omega_1%5B0%3Aalpha_1.shape%5B0%5D%2C%20%3A%5D.T).T%2C%20axis%3D1)%20-%20MFAcmLocal%0A%20%20%20%20plt.figure()%0A%20%20%20%20plt.plot(t_1%5B2%3A-2%5D%2C%20MA)%0A%20%20%20%20plt.legend(('longitudinal'%2C%20'sagittal'%2C%20'mediolateral'))%0A%20%20%20%20plt.title('Ankle%20Torque')%0A%20%20%20%20plt.xlabel('t%20(s)')%0A%20%20%20%20plt.ylabel('M%20(N.m)')%0A%20%20%20%20plt.show()%0A%20%20%20%20plt.figure()%0A%20%20%20%20plt.plot(t_1%5B2%3A-2%5D%2C%20FALocal%5B%3A%2C%200%5D)%0A%20%20%20%20plt.plot(t_1%5B2%3A-2%5D%2C%20FALocal%5B%3A%2C%201%5D)%0A%20%20%20%20plt.plot(t_1%5B2%3A-2%5D%2C%20FALocal%5B%3A%2C%202%5D)%0A%20%20%20%20plt.title('Ankle%20Force')%0A%20%20%20%20plt.legend(('longitudinal'%2C%20'sagittal'%2C%20'mediolateral'))%0A%20%20%20%20plt.xlabel('t%20(s)')%0A%20%20%20%20plt.ylabel('F%20(N)')%0A%20%20%20%20plt.show()%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Checkpoint%20questions%0A%0A%20%20%20%201.%20When%20is%20%24%5Cmathbf%20H%24%20parallel%20to%20%24%5Cboldsymbol%5Comega%24%3F%0A%20%20%20%202.%20Which%20term%20converts%20a%20body-frame%20derivative%20to%20an%20inertial%20derivative%3F%0A%20%20%20%203.%20Do%20Euler-angle%20derivatives%20generally%20equal%20angular-velocity%20components%3F%0A%20%20%20%204.%20What%20must%20be%20supplied%20before%20marker%20coordinates%20determine%20a%20joint%20moment%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%2F%2F%2F%20details%20%7C%20Checkpoint%20answers%0A%0A%20%20%20%201.%20Rotation%20along%20a%20principal%20axis%2C%20or%20an%20isotropic%20inertia%20tensor.%0A%20%20%20%202.%20%24%5Cboldsymbol%5Comega%5Ctimes%5Cmathbf%20H%24.%0A%20%20%20%203.%20No%3B%20they%20must%20be%20mapped%20using%20the%20chosen%20rotation%20sequence.%0A%20%20%20%204.%20Segment%20geometry%2Finertias%2C%20a%20frame%20convention%2C%20derivative%20estimates%20and%20all%20relevant%20external%20loads.%0A%20%20%20%20%2F%2F%2F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Problems%0A%0A%20%20%20%201)%20Compute%20the%20derivative%20of%20the%20angular%20momentum%20of%20the%20foot%20and%20the%20leg%20using%20one%20of%20%20the%20following%20data%20acquired%20during%20the%20gait%20of%20a%20subject%3A%20%5B'..%2Fdata%2FBiomecII2018_gait_d.txt'%5D(..%2Fdata%2FBiomecII2018_gait_d.txt)%20or%20%5B'..%2Fdata%2FBiomecII2018_gait_n.txt'%5D(..%2Fdata%2FBiomecII2018_gait_n.txt).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%2F%2F%2F%20details%20%7C%20Final%20answers%20to%20original%20Problems%0A%0A%20%20%20%201.%20For%20each%20segment%2C%20the%20required%20laboratory-frame%20derivative%20is%20%24%5Cdot%20H_G%3DR%5BI_B%5Cdot%5Comega_B%2B%5Comega_B%5Ctimes(I_B%5Comega_B)%5D%24.%20The%20marker%20files%20alone%20do%20not%20determine%20a%20unique%20numerical%20answer%3A%20specify%20segment%20mass%2Finertia%2C%20anatomical-frame%20construction%2C%20sampling%20interval%20and%20the%20differentiation%2Ffiltering%20procedure.%20The%20two%20recordings%20produce%20different%20time%20series.%20The%20final%20result%20is%20a%20three-component%20torque-unit%20series%20(N%20m)%2C%20not%20simply%20componentwise%20%24I_B%5Cdot%5Comega_B%24.%0A%20%20%20%20%2F%2F%2F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Go%20deeper%0A%0A%20%20%20%20Use%20%5BKineticsFundamentalConcepts%5D(https%3A%2F%2Fmolab.marimo.io%2Fgithub%2FBMClab%2FBMC%2Fblob%2Fmaster%2Fnotebooks%2Fkinetics_fundamental_concepts.py)%20to%20connect%20this%20guide%20with%20the%20surrounding%20mechanics%20and%20modeling%20material.%20Return%20to%20the%20assumptions%20behind%20each%20equation%20when%20applying%20it%20to%20a%20new%20experiment.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Optional%20textbook%20investigations%0A%0A%20%20%20%20These%20original%20external%20assignments%20require%20the%20stated%20edition%20and%20its%20figures.%20They%20are%20retained%20as%20optional%20reading%3B%20the%20self-contained%20Problems%20above%20have%20answer%20panels.%0A%0A%20%20%20%202)%20Problem%2020.2.7%20from%20Ruina%20and%20Rudra%20book.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Video%20lectures%20on%20the%20Internet%0A%0A%20%20%20%20%5BMIT%20OpenCourseWare%5D(https%3A%2F%2Focw.mit.edu%2Fcourses%2F2-003sc-engineering-dynamics-fall-2011%2Fpages%2Ffree-body-diagrams-and-fictitious-forces%2F)%20%E2%80%94%20Free-body%20diagrams%3A%20practice%20selecting%20a%20body%20and%20frame%20before%20writing%20force%20and%20moment%20equations.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20References%0A%0A%20%20%20%20-%20Beer%2C%20F%20P%3B%20Johnston%2C%20E%20R%3B%20Cornwell%2C%20P.%20J.(2010)%20Vector%20Mechanics%20for%20Enginners%3A%20Dynamics.%0A%0A%20%20%20%20-%20Kane%20T%2C%20Levinson%20D%20(1985)%20%5BDynamics%3A%20Theory%20and%20Applications%5D(https%3A%2F%2Fecommons.cornell.edu%2Fhandle%2F1813%2F638).%20McGraw-Hill%2C%20Inc%0A%0A%20%20%20%20-%20Hibbeler%2C%20R.%20C.%20(2005)%20Engineering%20Mechanics%3A%20Dynamics.%0A%0A%20%20%20%20-%20Taylor%2C%20J%2C%20R%20(2005)%20Classical%20Mechanics%0A%0A%20%20%20%20-%20Winter%20D.%20A.%2C%20(2009)%20Biomechanics%20and%20motor%20control%20of%20human%20movement.%20John%20Wiley%20and%20Sons.%0A%0A%20%20%20%20-%20Santos%20DA%2C%20Fukuchi%20CA%2C%20Fukuchi%20RK%2C%20Duarte%20M.%20(2017)%20A%20data%20set%20with%20kinematic%20and%20ground%20reaction%20forces%20of%20human%20balance.%20PeerJ%20Preprints.%0A%0A%20%20%20%20-%20Ruina%20A.%2C%20Rudra%20P.%20(2019)%20%5BIntroduction%20to%20Statics%20and%20Dynamics%5D(https%3A%2F%2Fruina.tam.cornell.edu%2FBook%2Findex.html).%20Oxford%20University%20Press.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
f4d3da1537aed4caaf65c6d3c50f3a98