About the code of sphere 3D ratation in yade

Asked by xuanshenyu

Hello, everyone!

I'm working on studying a new contact model based on the code of Yade.
I want to call the pose shapes of the particles and their 3D rotations at each time step.
But I didn't find code that handles 3D rotation of spherical particles.

May I ask that in which .cpp file is the code that implements the 3D rotation of the particles? and help to decipher the code.

Shenyu

Question information

Language:
English Edit question
Status:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

please be more specific.

> I want to call the pose shapes of the particles and their 3D rotations at each time step.

what does this, specifically "call pose shapes" exactly mean?

> But I didn't find code that handles 3D rotation of spherical particles.

what does "handle 3D rotation" mean?

The orientation / 3D rotation of particle is in python its b.state.ori, so the corresponding C++ code is inside core/State.hpp

It's main "usage" is probably in NewtonIntegrator, so ha a look there, pkg/dem/NewtonIntegrator.*
See also explanation in documentation [1]

b.state.ori is a quaternion [2].

Cheers
Jan

[1] https://yade-dem.org/doc/formulation.html#motion-integration , section Orientation
[2] https://en.wikipedia.org/wiki/Quaternion

Revision history for this message
xuanshenyu (shenyuxuan) said :
#2

Thanks for your reply, Jan!

>the mean is I want to the declear of quaternion and other parapmeter in C++ code, which are used to defined the 3D rotation. so I can call those parameter. And I have found the code in pkg/dem/NewtonIntegrator.* and Yade documentation.

>I'm learning a little bit about 3D ratation, and there are four ways to represent 3D ratation: Euler angle, aixs-angle, ratation matrix and quaternion[3]. However, I can't understand the code in pkg/dem/NewtonIntegrator.cpp as follow:

void NewtonIntegrator::leapfrogSphericalRotate(State* state, const Real& dt)
{
 if (scene->isPeriodic && homoDeform) { state->angVel += dSpin; }
 Real angle2 = state->angVel.squaredNorm();
 if (angle2 != 0) { //If we have an angular velocity, we make a rotation
  Real angle = sqrt(angle2);
  Quaternionr q(AngleAxisr(angle * dt, state->angVel / angle));
  state->ori = q * state->ori;
 }
 state->ori.normalize();
}

There are used the quaternion but the calculate method of quaternion is different from [3]. Could you help me explain this code? and from thoretical method to code implementatyion process.

Shenyu

[3]https://www.euclideanspace.com/maths/geometry/rotations/theory/index.htm

Revision history for this message
Jan Stránský (honzik) said :
#3

> I can't understand the code
> Could you help me explain this code?

Please be more specific, which part of code you do not understand (specific line, whole function, ...)

> There are used the quaternion but the calculate method of quaternion is different from [3]

Please be more specific, e.g. what is "calculate method of quaternion"

Cheers
Jan

Revision history for this message
Launchpad Janitor (janitor) said :
#4

This question was expired because it remained in the 'Needs information' state without activity for the last 15 days.