From: Chris Butcher (BUNGIE) <cbutcher@mi...>  20020228 00:01:28

> Original Message > From: Ratcliff, John [mailto:jratcliff@...] >=20 > What I need to be able to do is take the result of an impact event and = then > create a generic orientation, either quaternion or euler, I don't care > which, that can be passed on to other routines like for generating = decals or > oriented effects. >=20 If I understand you correctly, you're looking for a quaternion that = will rotate a Zaxisaligned object to face along a given vector. Take the cross product of this vector with +Z to get a rotation axis, = and the dot product of this vector with +Z (i.e. the Z component of the = vector) to give the cosine of the angle of the rotation. That gives you an axis a and a rotation magnitude cos(theta). Use = trigonometric identities to generate cos(theta/2) and sin(theta/2). You = can build the quaternion directly as: q.w =3D cos(theta/2) q.v =3D sin(theta/2)*normalize(a) The only real problem with this is that there's no control over the = 'roll' component of the rotation. If you wanted to modify that (e.g. by = randomizing it) you could premultiply by a random quaternion that is a = rotation about +Z.  Chris Butcher AI Engineer  Halo Bungie Studios butcher@... 