Accessing values from libCollision contact law

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing values from libCollision contact law

willstring
Hello,

I'm working on writing a custom contact law within the file libCollision/CallBack/Standard.cpp

I need some help figuring out the syntax to access the scalar components of the positions/displacements, quaternions, and normal vectors.

For example, if I have the vector CO1:

const Geom::Vector CO1(point, de1.Center());

Then how would I get just the x-component of the vector CO1 individually?  Is it simply CO1.x, CO1.y .... ?

Same question for  the quaternions: how would I pull the four quaternion values from an element "de1" individually?  Is it something line de1.GetQuaternion().x, de1.GetQuaternion().y, de1.GetQuaternion().z, and de1.GetQuaternion().t ?

And lastly for the vector const Geom::Vector& normal, is it again just normal.x, normal.y, and normal.z to access the x, y, and z components respectively?

Thank you again for the help :)

Reply | Threaded
Open this post in threaded view
|

Re: Accessing values from libCollision contact law

Damien André
Administrator
Hello, to get the component values of a vector you can use the X(), Y() and Z() method:
your_vector.X() = 0.;
your_vector.X() = 0.;
your_vector.Z() = 1.;

For a quaternion, you can use the X(), Y(), Z() and R() methods:
quaternion.X() = 0.;
quaternion.Y() = 0.;
quaternion.Z() = 0.;
quaternion.R() = 1.;
The R() method is related to the real part of the quaternion while the X(), Y(), Z() to the imaginary part.

You can take a look on the Lib/GranOO/libGeom/Quaternion.hpp and Lib/GranOO/libGeom/Vector.hpp source files.

Cheers, Damien.