void RVec4SetXYZ( RVec4* out, const RVec3* v ) { out->x = RVec3GetX( v ); out->y = RVec3GetY( v ); out->z = RVec3GetZ( v ); }
void RQuatSetXYZ( RQuat* out, const struct RVec3* v ) { out->x = RVec3GetX( v ); out->y = RVec3GetY( v ); out->z = RVec3GetZ( v ); }
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 ); }
/* 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 ); }