###

Question:

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 http://img688.imageshack.us/img688/5394/prettydiagram.png

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

###

Solution:1

It is simple, really.

`B = -1/2 * A`

, or `B.x = -1/2 * A.x`

, `B.y = -1/2 * A.y`

, `B.z = -1/2 * A.z`

. This talks about vectors, btw. You would want to shift the result. The formula is dead-simple. What am I missing?

*EDIT*

Your app knows the red dot location (let's abbreviate it as R vector). Your app also knows the A vector. It needs to find the B vector that is on the same line as AR, on the other side of R as A, and such as A is twice as far than B. Well, in that case:

- Temporarily calculate vector
`V = (A - R)`

- Now (It is simple :) ):
`B = R - 0.5 * V`

.

It is that simple, I promise. The capital letters represent vectors, which are generally 2-tuples or 3-tuples of real numbers (depending on whether you work in 2D or 3D).

There is not much to this, really. Any questions?

###

Solution:2

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 http://www.equationsheet.com/latexrender/pictures/46befe367f1c80ac00351de7785fd439.gif

Apply the transformation like this:

alt text http://www.equationsheet.com/latexrender/pictures/78c27d415d755a0be04e4747da351a09.gif

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 http://www.equationsheet.com/latexrender/pictures/3c16fd7210502fe391688e89f9b23589.gif

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.

**Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com**

EmoticonEmoticon