Dear Miguel,
Here is one approach to computing the axis and angle for a rotation that
will move a vector A = (x0, y0, z0) to B = (x1, y1, z1):
1) compute the normal to the plane containing the origin, A, and B by
computing the cross product of A and B. This is one possible axis for
such a rotation.
2) compute the angle between A and B, in the above plane, by finding
the length len1 of A, and the length len2 of B, and then
angle = acos((A.B)/(len1*len2))
Here A.B means the dot product of the two vectors.
3) Finally, make sure the sign of the angle is correct. It may be easiest
to check this by testing your code.
Once you have the axis and angle, you may be able to convert to other
representations of the rotation, e.g. a transformation, using a library
routine. For example, a library that handles quaternions should accept
axis, angle as a description for a quaternion, and also be able to output
a matrix.
Olaf
On Fri, 10 Sep 2004, Miguel wrote:
> I need to calculate the transformation matrix to position a particular
> atom (or point) directly in front of the user.
>
> I have a model made up of multiple points.
>
> I calculate an average of these points to be the center of rotation ...
> the origin.
>
> To position a particular atom in front of the user it seems to me that I
> need to:
> 1. calculate the vector from the origin/center-of-rotation to the point/atom
> 2. move that vector so that it is oriented at 0, 0, D on the z-axis
>
> I could calculate the angle, but I don't know how to calculate the axis of
> rotation to make this occur.
>
> QL Can one of you tell me how to calculate the transformation matrix to
> effect this change?
>
>
> Miguel
>
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Jmol-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jmol-developers