本文整理匯總了Python中sympy.physics.mechanics.Particle.linearmomentum方法的典型用法代碼示例。如果您正苦於以下問題:Python Particle.linearmomentum方法的具體用法?Python Particle.linearmomentum怎麽用?Python Particle.linearmomentum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sympy.physics.mechanics.Particle
的用法示例。
在下文中一共展示了Particle.linearmomentum方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_particle
# 需要導入模塊: from sympy.physics.mechanics import Particle [as 別名]
# 或者: from sympy.physics.mechanics.Particle import linearmomentum [as 別名]
def test_particle():
m, m2, v1, v2, v3, r = symbols('m m2 v1 v2 v3 r')
P = Point('P')
P2 = Point('P2')
p = Particle('pa', P, m)
assert p.mass == m
assert p.point == P
# Test the mass setter
p.mass = m2
assert p.mass == m2
# Test the point setter
p.point = P2
assert p.point == P2
# Test the linear momentum function
N = ReferenceFrame('N')
O = Point('O')
P2.set_pos(O, r * N.y)
P2.set_vel(N, v1 * N.x)
assert p.linearmomentum(N) == m2 * v1 * N.x
assert p.angularmomentum(O, N) == -m2 * r *v1 * N.z
P2.set_vel(N, v2 * N.y)
assert p.linearmomentum(N) == m2 * v2 * N.y
assert p.angularmomentum(O, N) == 0
P2.set_vel(N, v3 * N.z)
assert p.linearmomentum(N) == m2 * v3 * N.z
assert p.angularmomentum(O, N) == m2 * r * v3 * N.x
P2.set_vel(N, v1 * N.x + v2 * N.y + v3 * N.z)
assert p.linearmomentum(N) == m2 * (v1 * N.x + v2 * N.y + v3 * N.z)
assert p.angularmomentum(O, N) == m2 * r * (v3 * N.x - v1 * N.z)