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
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
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.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
You are one of the most smart/helpful people here. Thanks.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.