Archived

This topic is now archived and is closed to further replies.

vectors. rotating. 3d. blah.

This topic is 6041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

if I take 2 3d vectors, such as:
  1 2 \ | \ | \| * 
how do I calculate a third that would look like:
  1 2 3 \ | / \ | / \|/ * 
it's basically a 180 degree rotation of vector 1 using vector 2 as the axis of rotation, and all 3 will be lined up, but I'm an idiot and can't get it to work in 3d space. It's for making stuff bounce off of a surface. Edited by - smart_idiot on November 9, 2001 9:58:12 AM

Share on other sites
Try this:

Let your vector 1 be V1 = (x1, y1, z1)
and let your vector 2 be V2 = (x2, y2, z2)
V2, defining your axis of rotation, should be a unit vector for this procedure

Calculate the dot product between V1 and V2

v1dotv2 = x1*x2 + y1*y2 + z1*z1

Then, let a new vector be the component of V1 that is normal to V2,

VN = V1 - V2*v1dotv2

Now just subtract VN twice from V1 to get the reflection V3:

V3 = V1 - 2*VN = V1 - 2*V1 + 2*V2*v1dotv2

Or, simplifying just a bit,

V3 = 2*V2*v1dotv2 - V1

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share on other sites
You are one of the most smart/helpful people here. Thanks.

• 12
• 9
• 13
• 41
• 15