← Back to team overview

yade-users team mailing list archive

Re: [Question #687331]: How does the orientation of particle work in YADE?

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi,

1) you are interested in the math behind, really in the stored internal values x,y,z,w.
Internal values x,y,z,w are NOT directly axis and angle (although x,y,z,w and axis-angle can be computed one from the other).
So the random distribution you proposed would not lead to sensible results.

2) you are interested from "user point of view"
Then you do not need to bother with the internal values x,y,z,w at all.
All you need is to know that quaternion can be represented as axis-angle pair. This is how you create quaternion in Yade
b.state.ori = (1,2,3),pi # axis = Vector3(1,2,3), angle = pi
and how they are printed
print(b.state.ori) # Quaternion(axis,angle)

Then yes, choosing the AXIS COMPONENTS x,y,z randomly from range (-1,1) and ANGLE from range (0,2*pi)
axis = [random.uniform(-1,1) for _ in range(3)]
angle = random.uniform(0,2*pi)
b.state.ori = Quaternion(axis,angle)
can generate any possible orientation.

I am not sure with the distribution, have a look at [1] and further
referenced materials if you require uniform distribution.

cheers
Jan

[1]
https://eigen.tuxfamily.org/dox/classEigen_1_1Quaternion.html#title14

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