Fixed Matrix::rotate( Vec3 from, Vec3 to); was using to X from to derive

axis, which causes a left-handed rotation.  Fixed to from X to.
This commit is contained in:
Don BURNS
2001-12-11 17:00:29 +00:00
parent b3cfed2cb2
commit b9f1b7aa6f

View File

@@ -162,7 +162,10 @@ void Matrix::makeRot( const Vec3& from, const Vec3& to )
double d = from * to; // dot product == cos( angle between from & to )
if( d < 0.9999 ) {
double angle = acos(d);
Vec3 axis = to ^ from; //we know ((to) x (from)) is perpendicular to both
// For right-handed rotations, cross product must be from x to, not
// to x from
//Vec3 axis = to ^ from; //we know ((to) x (from)) is perpendicular to both
Vec3 axis = from ^ to; //we know ((from) x (to)) is perpendicular to both
makeRot( inRadians(angle) , axis );
}
else
@@ -174,7 +177,8 @@ void Matrix::makeRot( float angle, const Vec3& axis )
makeRot( angle, axis.x(), axis.y(), axis.z() );
}
void Matrix::makeRot( float angle, float x, float y, float z ) {
void Matrix::makeRot( float angle, float x, float y, float z )
{
float d = sqrt( x*x + y*y + z*z );
if( d == 0 )
return;