예제 #1
0
/* http://en.wikipedia.org/wiki/Rotation_representation_%28mathematics%29
   http://en.wikipedia.org/wiki/Rotation_matrix
*/
void
RMtx4RotationZ( RMtx4* out, rmReal radian )
{
    rmReal s = rmSin( radian );
    rmReal c = rmCos( radian );

    RMtx4Identity( out );
    SET_ELEMENT( out, 0, 0,  c );
    SET_ELEMENT( out, 0, 1, -s );
    SET_ELEMENT( out, 1, 0,  s );
    SET_ELEMENT( out, 1, 1,  c );
}
예제 #2
0
void
RQuatRotationAxis( RQuat* out, const struct RVec3* axis, rmReal radian )
{
    rmReal s = rmSin( radian / 2.0f );
    rmReal x, y, z, w;

    x = s * RVec3GetX( axis );
    y = s * RVec3GetY( axis );
    z = s * RVec3GetZ( axis );
    w = rmCos( radian / 2.0f );

    RQuatSetElements( out, x, y, z, w );
}
예제 #3
0
/* http://en.wikipedia.org/wiki/Rotation_matrix
 */
void
RMtx4RotationAxis( RMtx4* out, const RVec3* axis, rmReal radian )
{
    rmReal s = rmSin( radian );
    rmReal c = rmCos( radian );
    rmReal C = 1.0f - c;
    rmReal x = RVec3GetX( axis );
    rmReal y = RVec3GetY( axis );
    rmReal z = RVec3GetZ( axis );

    RMtx4Identity( out );
    SET_ELEMENT( out, 0, 0, x*x*C + c );
    SET_ELEMENT( out, 0, 1, x*y*C - z*s );
    SET_ELEMENT( out, 0, 2, z*x*C + y*s );
    SET_ELEMENT( out, 1, 0, x*y*C + z*s );
    SET_ELEMENT( out, 1, 1, y*y*C + c );
    SET_ELEMENT( out, 1, 2, y*z*C - x*s );
    SET_ELEMENT( out, 2, 0, z*x*C - y*s );
    SET_ELEMENT( out, 2, 1, y*z*C + x*s );
    SET_ELEMENT( out, 2, 2, z*z*C + c );
}