3D coordinate Transforms

Hi,
I thought I would share this patch as there have been many questions
in the past on this list about doing rotations and other trickiness
with 3d coordinates.  This patch doesn’t calculate rotations directly
but uses the homogeneous coordinate transform matrix (or more
accurately a bastardization of it) to more easily work with particular
situations that come up in 3-space.

The patch start with a vector (start and end point) and from there
derives a coordinate system with that vector as the x-axis.  It then
transforms the derived coordinate system to the standard xyz axes.

This technique is really usefull if you have an arbitrary line in
3-space and you want to operate on point in relation to that line
(like calculating a forcfield about a line).  It’s not very easy to
calculate certain geometric relations if the line can be anywhere, but
if you can be guaranteed to have the line always at say the x-axis,
you can reduce the complexity of your calculations.  Thus, the reason
for this patch…taking a line and rotating the entire space about
that line to be about the x-axis.

Enjoy.  I hope I’ve commented the JS file enough to make what I’m
doing straightforward.

Download at: http://www.mat.ucsb.edu/~whsmith/LineTrans.zip

cheers,
wes

Leave a Comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.