I'm trying to create an object which is rotated towards a specific point. I have a 3D vector of the positional difference, but TGE uses axis angles for rotation. I've tried the following three methods of conversion, but none of them work properly. Any ideas?
function vectorToAxis( %vector )
{
%normal = vectorNormalize( %vector );
%axis = vectorCross( %vector, %normal );
%angle = vectorDot( %vector, %normal );
return %axis SPC %angle;
}
function vectorToAxis( %vector )
{
%axis = vectorCross( %vector, "0 0 1" );
%angle = vectorDot( %vector, "0 0 1" );
return %axis SPC %angle;
}
function vectorToAxis( %vector )
{
%angle = mAtan( getWord( %vector, 1 ), getWord( %vector, 0 ) );
return "0 0" SPC %angle SPC 1;
}