← Back to team overview

yade-users team mailing list archive

Re: [Question #703712]: Use quaternion to transform coordinate system in yade

 

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

Description changed to:
Hi,everyone!

I try to use quaternion in yade source code to convert between granular
coordinate system and geodetic coordinate system.

Suppose there is a fixed point, p, on the particle, and its coordinate
is p1 in the particle coordinate system. We want to obtain the
coordinate p2 of the fixed point in the geodetic coordinate system under
each time step by the quaternion,Q, of this particle.

I wrote the following code:

###################### ############Ig2_Sphere_Sphere_ScGeom.cpp

bool Ig2_Sphere_Sphere_ScGeom::go(
        const shared_ptr<Shape>&       cm1,
        const shared_ptr<Shape>&       cm2,
        const State&                   state1,
        const State&                   state2,
        const Vector3r&                shift2,
        const bool&                    force,
        const shared_ptr<Interaction>& c)
{
	......
        const Se3r&   se31 = state1.se3;
        const Sphere *s1 = static_cast<Sphere*>(cm1.get()), *s2 = static_cast<Sphere*>(cm2.get());
        Vector3r p1(0,0,s1->radius);
        Vector3r p2;
        p2=Quaternionr(se31,orientation).inverse()*(p1-se31.position)  //p2=Q^-1*(p1-position)
       ......
}
################

May I ask if this method is correct?

Thanks for your help :).

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