Question of a function in helpsv_3_0_0.cpp

Raheem Sterling_22160
Raheem Sterling_22160 Altair Community Member
edited April 2023 in Community Q&A

Hi,

I want to rotate a 3D vector with a vector at a certain angle, I find a function in helpsv_3_0_0.cpp as below:

Is the Rodrigues' rotation equation implemented here? I am not sure because it seems a different with original equation.

 inline CSimple3x3Matrix::CSimple3x3Matrix(const CSimple3DVector& vector, double rotangle)     {         double c = cos(rotangle);         double s = sin(rotangle);          m_xx = 1 + ( 1 - c ) * ( vector.getX() * vector.getX() - 1 );         m_xy = -vector.getZ() * s + ( 1 - c ) * vector.getX() * vector.getY();         m_xz = vector.getY() * s + ( 1 - c ) * vector.getX() * vector.getZ();         m_yx = vector.getZ() * s + ( 1 - c ) * vector.getX() * vector.getY();         m_yy = 1 + ( 1 - c ) * ( vector.getY() * vector.getY() - 1 );         m_yz = -vector.getX() * s + ( 1 - c ) * vector.getY() * vector.getZ();         m_zx = -vector.getY() * s + ( 1 - c ) * vector.getX() * vector.getZ();         m_zy = vector.getX() * s + ( 1 - c ) * vector.getY() * vector.getZ();         m_zz = 1 + ( 1 - c ) * ( vector.getZ() * vector.getZ() - 1 );      }
Tagged:

Answers

  • RWood
    RWood
    Altair Employee
    edited April 2023

    Hi,

    Yes it is. It's a matrix form of Rodrigues' rotation formula. If you take a look at :

    https://en.wikipedia.org/wiki/Rotation_matrix

    and scroll down to "Rotation matrix from axis and angle" that is the implementation you see, only we have it in a slightly different format. If you want to convince yourself then multiply out all the terms and you will end up with what you see on Wikipedia, which as I say is a derivation from Rodrigues.

    Cheers,

    Richard

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited April 2023

    Hi,

    Yes it is. It's a matrix form of Rodrigues' rotation formula. If you take a look at :

    https://en.wikipedia.org/wiki/Rotation_matrix

    and scroll down to "Rotation matrix from axis and angle" that is the implementation you see, only we have it in a slightly different format. If you want to convince yourself then multiply out all the terms and you will end up with what you see on Wikipedia, which as I say is a derivation from Rodrigues.

    Cheers,

    Richard

    Hi Richard,

    Thank you very much, I want to make sure that, for v_rot = R v_original, this code is the matrix R. And the coefficient in this function: vector is the unit rotation axis, angle is the rotation angle.

    So if I want to know a vector v_original connected by the center of particle and one of point on the surface,when rotating through one time step, can I write like this:

    double Rotation_angle = element1.angVel.length() * timeStepData.timeStep; CSimple3DVector ki_rot = element1.angVel;     ki_rot.normalise(); CSimple3x3Matrix R(ki_rot, Rotation_angle); CSimple3DVector v_rot = v_original.operate*(R)

    Regards!

    Raheem

  • RWood
    RWood
    Altair Employee
    edited April 2023

    Hi Richard,

    Thank you very much, I want to make sure that, for v_rot = R v_original, this code is the matrix R. And the coefficient in this function: vector is the unit rotation axis, angle is the rotation angle.

    So if I want to know a vector v_original connected by the center of particle and one of point on the surface,when rotating through one time step, can I write like this:

    double Rotation_angle = element1.angVel.length() * timeStepData.timeStep; CSimple3DVector ki_rot = element1.angVel;     ki_rot.normalise(); CSimple3x3Matrix R(ki_rot, Rotation_angle); CSimple3DVector v_rot = v_original.operate*(R)

    Regards!

    Raheem

    Off the top of my head that looks about right to me, but I'd do some simple checks with unit vectors first to make sure. For example, rotating one of the base x/y/z unit vectors through a few simple angles (30/45/60 deg) so you can verify by hand it's as you would expect.

    Richard