Хочу написать конвертер IPL>PWN и я заступорился... как перевести Кватернионы в градусы и обратно? нашел функцию но не знаю как нормально переделать ее под павн.
Code
inline void unit_from_axis_angle(const vector3& axis, const float& angle){
vector3 v(axis);
v.norm();
float half_angle = angle*0.5f;
float sin_a = (float)sin(half_angle);
set(v.x*sin_a, v.y*sin_a, v.z*sin_a, (float)cos(half_angle));
};
//-----------------------------------
/**
convert a quaternion to axis angle representation,
preserve the axis direction and angle from -PI to +PI
*/
inline void to_axis_angle(vector3& axis, float& angle)const {
float vl = (float)sqrt( x*x + y*y + z*z );
if( vl > TINY )
{
float ivl = 1.0f/vl;
axis.set( x*ivl, y*ivl, z*ivl );
if( w < 0 )
angle = 2.0f*(float)atan2(-vl, -w); //-PI,0
else
angle = 2.0f*(float)atan2( vl, w); //0,PI
}else{
axis = vector3(0,0,0);
angle = 0;
}
};
Как переделать эту функцию, или есть ли другой способ перевода?