← Back to team overview

yade-users team mailing list archive

[Question #705414]: Accessing Quaternions' Components

 

New question #705414 on Yade:
https://answers.launchpad.net/yade/+question/705414

Hello everyone,

I am working with clumps in YADE, and I need their orientations. I get the orientations using .state.ori and it returns a Quaternion. However, I am having trouble accessing the components of the Quaternions. For example, suppose we have a quaternion assigned to a variable q as follows:

q = Quaternion((-0.5511712429622227516,0.6264347706369409741,-0.5511712429622227516),2.022331863044346534)

When I try to access the components of this quaternion using q[0], q[1], q[2], q[3]; 
it returns -0.4670908316044708, 0.5308730121517236, -0.4670908316044708, 0.5308730121517236, respectively. The individual components are different than that is in the Quaternion. I am also sending the script that generates the same output:



# To create clumps, I used a part of the code at https://gitlab.com/yade-dev/trunk/blob/master/examples/clumps-breakage/uniaxial_clump.py


sphere_list_three = [[[0, -3e-3, 0], 7e-3], [[0, 3e-3, 0], 7e-3], [[0, 0, 3e-3], 8e-3]]
O.bodies.appendClumped([sphere(s[0], s[1]) for s in sphere_list_three], discretization=10)

# check if the body is a clump
for b in O.bodies:
	print(b, b.isClump)

# Last body is a clump. Assign its orientation to clump_ori
clump_ori = O.bodies[-1].state.ori

# print its Quaternion and its components 
print(f"\nQuaternion: {clump_ori}\n")
print(f"1st element: {clump_ori[0]}")
print(f"2nd element: {clump_ori[1]}")
print(f"3rd element: {clump_ori[2]}")
print(f"4th element: {clump_ori[3]}")



I did not understand the behavior. Thank you in advance if you help me.

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