yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #21334
Re: [Question #686076]: Problem of Bodies rotation
Question #686076 on Yade changed:
https://answers.launchpad.net/yade/+question/686076
yang yi posted a new comment:
Thank you very much!! Jan Stránský
Now I have two problem
(1) for using RotationEngine, I hope the following code can change
the direction of the plane by the PyRunner function ChangeVelocity, but
it cannot, the value of Velocity can be changed, but the plane still
Rotation as the initial speed and direction.
velocity = 10
def ChangeVelocity():
global velocity
velocity = -1 * velocity
O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
InteractionLoop(
# handle sphere+sphere and facet+sphere collisions
[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]),
# [Ip2_ViscElMat_ViscElMat_ViscElPhys()],
# [Law2_ScGeom_ViscElPhys_Basic()]),
NewtonIntegrator(gravity=(-9.8, 0, 0), damping=0.001, label='down'),
RotationEngine(rotationAxis=(0, 0, 1), angularVelocity=velocity, rotateAroundZero=True, zeroPoint=(0, 0, 0)),
PyRunner(command="ChangeVelocity()", iterPeriod=100000)
]
(2) The problem of transform the C++ code of RotationEngine to python,
I hope I can control the rotation velocity of the plane.
def myRotation():
ZeroPos = Vector3(1, 1, 0)
rotationAxis = Vector3(0, 0, 1)
angVel = 10
for i in IDGround:
O.bodies[i].state.angVel += rotationAxis * angVel
l = O.bodies[i].state.pos - ZeroPos
q = Quaternion(AngleAxis(rotationAxis, angVel* O.dt))
# q = Quaternion(rotationAxis, angVel * O.dt)
newp = q*l + ZeroPos
O.bodies[i].state.vel += (newp - O.bodies[i].state.pos)/O.dt
O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
InteractionLoop(
# handle sphere+sphere and facet+sphere collisions
[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]),
# [Ip2_ViscElMat_ViscElMat_ViscElPhys()],
# [Law2_ScGeom_ViscElPhys_Basic()]),
NewtonIntegrator(gravity=(-9.8, 0, 0), damping=0.001, label='down'),
PyRunner(command="myRotation()",iterPeriod=400000)
# RotationEngine(rotationAxis=(0, 0, 1), angularVelocity=velocity, rotateAroundZero=True, zeroPoint=(0, 0, 0)),
# PyRunner(command="ChangeVelocity()", iterPeriod=100000)
]
I can find the "AngleAxis", and the error is "name 'AngleAxis' is
not defined". The above code is follow the C++ in the
KinematicEngines.cpp. I don't know if the transform is correct or
not.
Please help me,Thank you very much,
--
You received this question notification because your team yade-users is
an answer contact for Yade.