obsidian_backup/补课/多体动力学/16_generalized_forces.ipynb

103 lines
2.2 KiB
Plaintext
Raw Normal View History

2025-03-21 14:31:35 +08:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle l \\dot{q}_{1}\\mathbf{\\hat{a}_x} + l \\dot{q}_{2}\\mathbf{\\hat{b}_x}$"
],
"text/plain": [
"l⋅q₁̇ a_x + l⋅q₂̇ b_x"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sympy as sm\n",
"import sympy.physics.mechanics as me\n",
"me.init_vprinting(use_latex='mathjax')\n",
"\n",
"l = sm.symbols('l')\n",
"q1, q2, u1, u2 = me.dynamicsymbols('q1, q2, u1, u2')\n",
"\n",
"N = me.ReferenceFrame('N')\n",
"A = me.ReferenceFrame('A')\n",
"B = me.ReferenceFrame('B')\n",
"\n",
"A.orient_axis(N, q1, N.z)\n",
"B.orient_axis(N, q2, N.z)\n",
"\n",
"O = me.Point('O')\n",
"P1 = me.Point('P1')\n",
"P2 = me.Point('P2')\n",
"\n",
"O.set_vel(N, 0)\n",
"\n",
"P1.set_pos(O, -l*A.y)\n",
"P2.set_pos(P1, -l*B.y)\n",
"\n",
"P1.v2pt_theory(O, N, A)\n",
"P2.v2pt_theory(P1, N, B)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle l \\cos{\\left(q_{1} \\right)} \\dot{q}_{1}\\mathbf{\\hat{n}_x} + l \\sin{\\left(q_{1} \\right)} \\dot{q}_{1}\\mathbf{\\hat{n}_y}$"
],
"text/plain": [
"l⋅cos(q₁)⋅q₁̇ n_x + l⋅sin(q₁)⋅q₁̇ n_y"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"P1.vel(N).express(N)"
]
2025-03-23 12:18:58 +08:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 两杆连接"
]
2025-03-21 14:31:35 +08:00
}
],
"metadata": {
"kernelspec": {
2025-03-23 12:18:58 +08:00
"display_name": "Turtle",
2025-03-21 14:31:35 +08:00
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2025-03-23 12:18:58 +08:00
"version": "3.11.8"
2025-03-21 14:31:35 +08:00
}
},
"nbformat": 4,
"nbformat_minor": 2
}