Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I always struggle with intuitively figuring out the order of subtraction in multiple situations for example

The difference between the current mouse coordinates and the last frame's coordinates

The direction an object is to the camera position

etc.

I know that A - B = A + (-B) ..my problem is figuring out which one is A and which one is B ..and those were just simple examples

Is there any hard and fast rules for this? Or is it supposed to be intuitive and obvious (which is what I'm afraid of)?

I have similar problems with figuring out which order to take the cross-product of two vectors too, depending on the scenario

share|improve this question

3 Answers 3

up vote 1 down vote accepted

Draw it all out on paper. Do it in 1D (ie. a number line), then do it in 2D (ie. a square grid).

Draw point B for the current mouse position, then point A for the previous position. B-A gets you the total change in 1D or 2D or 3D and why is very easy to see on the 1D number line.

Stop calling the points A and B until later, try calling them Now and Then. If you take Now minus Then you get what happened between Now and Then.

As for cross products keep in mind that positive rotation is counter-clockwise. So if you have 2D vectors drawn out on paper with points ABC if you look at it and BA is counter-clockwise to BC then the cross result will be up out of the paper towards your face.

If you hold your right hand out, index straight out, next finger turned left and thumbs up that shows the "right hand rule" for what side is what in 3D and it describes visually what you just drew in 2D.

share|improve this answer
2  
The last paragraph is why some math and physics exams can be hilarious to watch. Particularly if magnetic fields are involved :) –  Anton Jul 14 '12 at 21:31

The cross product is fairly simple. You just use the right hand rule, where your 4 fingers make the notion of going from the first vector to the second and the thumb points in the direction the product vector will be pointing.

As for vector subtracting, let's say you have two points. Then if you subtract point A from point B (it doesn't actually make sense from the stand point of mathematics, but you represent vectors like you do points, where the tail is at the origin and the head is at the given point) then you'll get a vector going from point A to point B. These things are easiest to visualize if you only account for the first quarter of the coordinate system (the x and y axii are positive). Same for vectors, if you have two vectors a and b, then subtracting a from b will result in a vector going from the tip of a to the tip of b.

share|improve this answer

For vector subtraction, I use the mental image of drawing a bow. If I'm subtracting A - B, I visualize holding up a bow with the arrow point at A, then drawing it back till the tail of the arrow is at B. The arrow is the result of subtraction, a vector pointing from B to A.

For cross products, dreta's and Patrick's answers already described the two most common methods.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.