Question #688763 on Yade changed: https://answers.launchpad.net/yade/+question/688763
Jan Stránský posted a new comment: Hi, sorry for late answer.. > Because in my simulation I still have some particles, the particles also have the orientations, I just want the shaft rotates under certain degrees. so I use, "for b in O.bodies" and "if isinstance(b.shape,Facet):" to isolate the degrees that the shaft has been rotated. in principle it should work as it is now, but the for loop is no necessary and overall it more error prone IMO cylinderRot and coneRot controls all of its bodies, so it should be sufficient to only use e.g. its first body: ### def ossillation_rotation(): i = cylinderRot.ids[0] b = O.bodies[i] rotationAngle = b.state.rot().norm() # needs to update, but the point is using just one body if rotationAngle > 0 ... ... else: ... ### > so if I want the shaft rotates 200 degrees, I can't use,O.bodies.state.rot().nrom(), this command?? yes, you cannot use it. As I have written, the solution is to store actual rotation and add incrementally the rotation increment to the stored value. MWE with one facet: ### 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 ### cheers Jan [1] -- You received this question notification because your team yade-users is an answer contact for Yade. _______________________________________________ Mailing list: https://launchpad.net/~yade-users Post to : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp