views:

97

answers:

2

I need to know how to find a vector opposite to another, but the second vector is not necessarily the same magnitude as the first, but the direction is opposite. Ex:

I made a small diagram :) alt text

Basically if I have the coordinates of A(-150,150) and I want B to be opposite, and have a magnitude of only 2, I would want to obtain B(-200,-150). What I am doing is making an application that can draw cubic bezier shapes and I noticed with lots of these, there are bezier handles and modifying one handle cause the other one to move too. How could this be done?

Thanks

+2  A: 
Hamish Grubijan
What do you mean by shift the results?
Milo
@Jex Since you already know A and B, are you trying to find the coordinate of a red dot? I am confused.
Hamish Grubijan
@Jex, if you have a directional line segment from `(2,3)` to `(9,-6)`, then it is really the vector `(7, -9)` shifted by vector `(2,3)` - meaning that you would pretend that `(2,3)` is the origin.
Hamish Grubijan
No, assuming I do not know B, I was thinking of rotating A around the red dot 180 degs but this does not make it smaller or larger.
Milo
@Jex, what are the coordinates of a red dot?
Hamish Grubijan
does it matter, its just an arbitrary example,but in my program I'd know it
Milo
my application knows red dot, and A, and knows length Red Dot to A and Length Red dot to B
Milo
Alright thank you very much for this explanation :)
Milo
+3  A: 

All you have to do is calculate the unit vector of the original vector by dividing each component by the magnitude of the vector and then apply a rotational transformation about a 180 degree angle.

The rotational transformation matrix looks like this:

alt text

Apply the transformation like this:

alt text

The primed vector is now the unit vector pointing in the direction you want. You can scale it by any magnitude you wish.

In your special case the angle is 180 degrees. You know that the cosine of 180 is -1 and the sine is zero, so the matrix is simple:

alt text

This makes it clear as day: All you have to do is reverse the signs of the two unit vector components and you have your answer.

duffymo
-1 for making something ridiculously simple look complicated.
R..
Just giving the background story for those who might be interested. Agreed, it's not complicated, but the back story allows you to understand how to handle the general case. It's only complicated to people who don't know vectors and are frightened of mathematics.
duffymo