# Quaternion representation of aspherical particels

Quote from Clemens Vorsmann on January 20, 2020, 6:09 pmI'm currently simulating a system consisting of spherocylinders, where every spherocylinders is defined by its radius and the two

points p1, p2 in the center of the hemispheres. I tried using the extended xyz format, but didn't find any information in the docs about:

- which point in the spherocylinder is the "position"?
- relative to which axis is the orientation defined?
So far I assumed the "position" is the center of the spherocylinder (p1+p2)/2 , the rotational axis is the axis, which is perpendicular

to the line p1p2 and the rotational angle is the angle given by the dot product of p1*p2. But this doesn't give me the expected pictures.

As an example I tried a particle with p1=(1/2,1/2,1/2) , p2=(5,5,5) and radius R = 1/2 , with which I created the particle_positions.exyz.

I'm currently simulating a system consisting of spherocylinders, where every spherocylinders is defined by its radius and the two

points p1, p2 in the center of the hemispheres. I tried using the extended xyz format, but didn't find any information in the docs about:

- which point in the spherocylinder is the "position"?
- relative to which axis is the orientation defined?

So far I assumed the "position" is the center of the spherocylinder (p1+p2)/2 , the rotational axis is the axis, which is perpendicular

to the line p1p2 and the rotational angle is the angle given by the dot product of p1*p2. But this doesn't give me the expected pictures.

As an example I tried a particle with p1=(1/2,1/2,1/2) , p2=(5,5,5) and radius R = 1/2 , with which I created the particle_positions.exyz.

**Uploaded files:**

Quote from Alexander Stukowski on January 20, 2020, 6:28 pmHi,

Yes, the "Position" particle property specifies the location of the center of the spherocylinders, i.e. the point halfway between the two hemispheres.

If the "Orientation" particle property is not present, the spherocylinders are rendered in a default reference orientation, which is defined such that the cylinder is aligned with the z-axis of the simulation coordinate system. The "Aspherical Shape.X" property controls the radius of the cylinder, and the "Aspherical Shape.Z" property controls the length of the cylinder, i.e. the distance between the two hemisphere centers.

If the "Orientation" property is present, it controls the rotation of the spherocylinder away from the reference orientation described above. Note that the "Orientation" property is not specified in terms of a rotation around a specific axis but rather as a full 3-dimensional rotation encoded as a quaternion. If you orientations are specified in a different, e.g. as direction vectors or something else, it currently is your responsibility to convert these orientations into the quaternion representation expected by OVITO.

In case your orientations are given in terms of the cylinder axis vectors, perhaps the following discussion can help you figure out the corresponding quaternions:

https://stackoverflow.com/questions/1171849/finding-quaternion-representing-the-rotation-from-one-vector-to-another

You would need to find the quaternion rotation that aligns the vector

u=(0,0,1)with some target vectorv(specifying the cylindrical axis of the rotated spherocylinder).-Alex

Hi,

Yes, the "Position" particle property specifies the location of the center of the spherocylinders, i.e. the point halfway between the two hemispheres.

If the "Orientation" particle property is not present, the spherocylinders are rendered in a default reference orientation, which is defined such that the cylinder is aligned with the z-axis of the simulation coordinate system. The "Aspherical Shape.X" property controls the radius of the cylinder, and the "Aspherical Shape.Z" property controls the length of the cylinder, i.e. the distance between the two hemisphere centers.

If the "Orientation" property is present, it controls the rotation of the spherocylinder away from the reference orientation described above. Note that the "Orientation" property is not specified in terms of a rotation around a specific axis but rather as a full 3-dimensional rotation encoded as a quaternion. If you orientations are specified in a different, e.g. as direction vectors or something else, it currently is your responsibility to convert these orientations into the quaternion representation expected by OVITO.

In case your orientations are given in terms of the cylinder axis vectors, perhaps the following discussion can help you figure out the corresponding quaternions:

You would need to find the quaternion rotation that aligns the vector *u=(0,0,1)* with some target vector *v* (specifying the cylindrical axis of the rotated spherocylinder).

-Alex

Quote from Clemens Vorsmann on January 20, 2020, 8:02 pmThank you for your quick reply! What I missed was that the reference orientation is the z-axis.

The pseudocode from the linked stackoverflow discussion was also helpful:

quaternion q;vector3 c = cross(v1,v2);q.v = c;if ( vectors are known to be unit length ) {q.w = 1 + dot(v1,v2);}else {q.w = sqrt(v1.length_squared() * v2.length_squared()) + dot(v1,v2);}q.normalize();returnq;One problem left is that I can't get ovito to automatically recognize the "Aspherical Shape" parameter from the column mapping.

My file looks like this:

...

Properties=pos:R:3:Orientation:R:4:aspherical_shape:R:3

...ovito then recognizes it as "aspherical_shape", but not as "Aspherical Shape". Putting "Aspherical Shape" into the properties doesn't

work either.

Thank you for your quick reply! What I missed was that the reference orientation is the z-axis.

The pseudocode from the linked stackoverflow discussion was also helpful:

*quaternion q;*
*vector3 c = cross(v1,v2);*
*q.v = c;*
*if ( vectors are known to be unit length ) {*
* q.w = 1 + dot(v1,v2);}*
* else {*
* q.w = sqrt(v1.length_squared() * v2.length_squared()) + dot(v1,v2);}*
*q.normalize();*
*return* q;

One problem left is that I can't get ovito to automatically recognize the "Aspherical Shape" parameter from the column mapping.

My file looks like this:

*...*

*Properties=pos:R:3:Orientation:R:4:aspherical_shape:R:3*

*...*

ovito then recognizes it as "aspherical_shape", but not as "Aspherical Shape". Putting "Aspherical Shape" into the properties doesn't

work either.

Quote from Constanze Kalcher on January 21, 2020, 9:54 amHi Clemens,

in the developer version, the property "aspherical_shape" is automatically recognized, see attached screenshot.

If for some reason you cannot upgrade, you can manually edit the file-column mapping in the 2.9 release (also marked in the screenshot) and rename the particle property aspherical_shape to Aspherical Shape.-Constanze

Hi Clemens,

in the developer version, the property "aspherical_shape" is automatically recognized, see attached screenshot.

If for some reason you cannot upgrade, you can manually edit the file-column mapping in the 2.9 release (also marked in the screenshot) and rename the particle property aspherical_shape to Aspherical Shape.

-Constanze

**Uploaded files:**