← Back to team overview

yade-users team mailing list archive

Re: [Question #692057]: The meaning of O.bodies.state.ori/refOri

 

Question #692057 on Yade changed:
https://answers.launchpad.net/yade/+question/692057

    Status: Open => Answered

Jan Stránský proposed the following answer:
> How to calculate this incremental rotation angle?

see [3] for discussion (code below)

> ... radian or degree?

radian

cheers
Jan


###
b = facet(((0,0,0),(1,0,0),(0,1,0)))
O.bodies.append(b)
b.state.angVel = (0,0,.1)

rot = 0
ori = b.state.refOri

def updateRot(b,rot,ori): # works for rotation aroud z axis
   relRot = ori.conjugate()*b.state.ori # same as State.rot(), https://gitlab.com/yade-dev/trunk/-/blob/master/core/State.hpp#L40
   axis,angle = relRot.toAxisAngle() # get axis and angle from quaternion
   if (axis[2]) < 0: # "negative" rotation ...
      angle *= -1 # ... negate the positive angle
   rot += angle # updates rotation angle
   ori = b.state.ori # "store" new orientation value
   return rot,ori

for i in range(20):
   O.step()
   rot,ori = updateRot(b,rot,ori)
   print i,rot

b.state.angVel = (0,0,-.3)

for i in range(40):
   O.step()
   rot,ori = updateRot(b,rot,ori)
   print i,rot
###

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.