Skip to main content
GameDev.net gamedev.net
🔒 Locked

What do dot-products and cross-products mean?

Started by Samith Jun 18, 2004 at 6:52 PM 21 replies 7.5k views
Original Post
Samith
Samith
I know what both the dot product and cross product are equation wise, but what do they really *mean*?
Ra
Ra
dot product: the cosine of the angle between two vectors

cross product: returns a vector perpendicular to the two input vectors
Ra
Guimo
Guimo
Just a little addenda...

If you need to compute the angle formed by two vectors you use cross and with a little math you get what you need.

The cross product returns a vector perpendicular to the two input vectors. YOU GET THE DIRECTION USING A 'RIGHT HAND' RULE...

Luck!
Guimo

bytecoder
bytecoder
Did you try google? Either way, I assume you mean what significance they have? A dot product between two vectors can tell you two things based on what the result is:
<0: the vectors form an obtuse angle.
=0: the vectors are perpendicular.
>0: the vectors form an acute angle.
This can be used to tell where a certain point is relative to a plane if you use the plane's normal vector, which is the vector perpendicular to the plain.
The dot product, as already stated, returns a vector perpendicular to both input vectors, allowing you to calculate the normal vector of a plane.
Samith
Samith
Ahh thanks guys. I see dot products all the time in some collision detection things and I never knew why they were there or what significance they had.

sirSolarius
sirSolarius
Quote:
Original post by Guimo

The cross product returns a vector perpendicular to the two input vectors. YOU GET THE DIRECTION USING A 'RIGHT HAND' RULE...


In a right-handed system... you need the left-hand rule for a left-handed system. For reference, OpenGL is right-handed and DirectX is left-handed.
Alpha_ProgDes
Alpha_ProgDes
Quote:
Original post by bytecoder

Did you try google? Either way, I assume you mean what significance they have? A dot product between two vectors can tell you two things based on what the result is:
<0: the vectors form an obtuse angle.
=0: the vectors are perpendicular.
>0: the vectors form an acute angle.
This can be used to tell where a certain point is relative to a plane if you use the plane's normal vector, which is the vector perpendicular to the plain.
The dot product, as already stated, returns a vector perpendicular to both input vectors, allowing you to calculate the normal vector of a plane.

-1 if they are 180 degrees from each other
1 if they are 0 degrees (ie. same direction)

right?
Beginner in Game Development?  Read here. And read here.  
prh99
prh99
Quote:
Original post by Samith

I know what both the dot product and cross product are equation wise, but what do they really *mean*?


I found this article somewhat helpful in dealing with cross products and dot products.
Patrick
JohnBolton
JohnBolton
What do the mean? What do addition and subtraction mean? They don't mean anything -- they are operations that can be used for different purposes.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Kasper Fauerby
Kasper Fauerby
Noone seems to have mentioned that the dot product only returns the cosine of the angle between two vectors if they are *normalized* !!

The general rule is that given two vectors v1 and v2:

dot(v1,v2) = cos(A) * length(v1) * length(v2)

where A is the angle between the vectors.

Therefore, as someone said a bit higher in this thread:

"-1 if they are 180 degrees from each other
1 if they are 0 degrees (ie. same direction)"

This is also only true for normalized vectors.

- Kasper
Muzzafarath
Muzzafarath
Quote:

Noone seems to have mentioned that the dot product only returns the cosine of the angle between two vectors if they are *normalized* !!


Well, not "only" when they are normalized. Consider length(v1) = 2 and length(v2) = 1/2...
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Kasper Fauerby
Kasper Fauerby
Heh.. ok, you got me there. But I would consider that a quite special case and one should probably keep the general rule in mind whenever it is not certain that both arguments to the dot product is normalized.

- Kasper
Alpha_ProgDes
Alpha_ProgDes
i take it when you say normalized you mean the vectors having a length of 1 unit (well that's what they called it in my class)? basically they must be unit vectors.

why is that again? it's been awhile since i've had to use physics.[imwithstupid]
Beginner in Game Development?  Read here. And read here.  
python_regious
python_regious
Here's my two pence.

The dot product is a projection operation. When you perform the dot product of two vectors (a.b), you find the length of the projection of vector a on b. Or, in other words, you find the length of vector a, in the b direction. It can be used to find the angle between vectors, but it is essentially a projection operation, not a "find the angle inbetween" operation.

The cross product operation returns a vector, of magnetude proportional to the magnetudes and angle between the crossed vectors. It's direction is determined by the right hand side screw rule ( I've never heard of a left hand version ). Using the determinant version of the cross-product operator, it becomes apparent where the magnetude of the result comes from ( if you consider that the determinant is the result of all possible permutaions of a matrix - it's "volume" ), and why it points in the direction it does.
If at first you don't succeed, redefine success.
python_regious
python_regious
Quote:
Original post by Alpha_ProgDes
i take it when you say normalized you mean the vectors having a length of 1 unit (well that's what they called it in my class)? basically they must be unit vectors.

why is that again? it's been awhile since i've had to use physics. *I'm not going to post myself as stupid*


Take the equation:

a.b = |a||b|cosine( theta )

If |a||b| doesn't equal 1, then a.b will not equal the cosine of the angle inbetween them. A case when a.b = cosine( theta ) is when both a and b are unit vectors. Of course, if the magnetude of one happens to be the reciprical of the magentude of the other, then this will also be true.
If at first you don't succeed, redefine success.
Zorodius
Zorodius
Quote:
Original post by python_regious
The dot product is a projection operation. When you perform the dot product of two vectors (a.b), you find the length of the projection of vector a on b. Or, in other words, you find the length of vector a, in the b direction. It can be used to find the angle between vectors, but it is essentially a projection operation, not a "find the angle inbetween" operation.

Just like with the interpretation that "it's the cosine of the angle between the two vectors", the "projection" interpretation is subject to the caveat that you have to be projecting onto the unit vector.

The projection of a non-unit vector onto a unit vector is the same as the dot product of the nonunit vector and unit vector.

The projection of a unit vector onto a non-unit vector is not the same as the dot product of the nonunit vector and unit vector.

The dot product is commutative, but the idea associated with it isn't.

Edit: Although I guess it depends on what you mean by "projection" ;) If the projection of vector V onto vector U should be the same as the projection of vector V onto an axis that passes through U, then the above holds. If you think of it differently, such as thinking that the projection onto a shorter vector should have a shorter length, then the "projection" interpretation could be valid in every case.
You don't need to vote for the "lesser of two evils"! Learn about Instant Runoff Voting, the simple cure for a broken democracy!
python_regious
python_regious
Quote:

the "projection" interpretation is subject to the caveat that you have to be projecting onto the unit vector.


What? No it isn't.

Quote:


The projection of a non-unit vector onto a unit vector is the same as the dot product of the nonunit vector and unit vector.

The projection of a unit vector onto a non-unit vector is not the same as the dot product of the nonunit vector and unit vector.


Thats just, well, wrong. The dot product calculates a projection, they are not mutually exclusive. Think of the equation:

c = |a||b|cos( theta )

That is blatently a projection operation. Think back to basic trig now.

The idea that it's a projection is not dependant on unit vectors at all. If you project vector a onto vector b, the result is the length of a on b ( i.e. you project a onto b ), neither have to be unit vectors. Just because the resultant scalar is a proportion of the length of b, and not an absolute value does not make it any less of a projection.

Quote:

If the projection of vector V onto vector U should be the same as the projection of vector V onto an axis that passes through U


I have no idea what you're saying here, this has absolutely nothing to do with "axis". If you think of the more general case of a frame ( 3 basis vectors - not necessarily unit or orthogonal ), then axis doesn't really mean anything. If you have unit, orthogonal basis vectors, then you have the classical "axis" sense. If you dot a vector ( c ) with one of these basis vector, you get the absolute coordinate in that axis. However, what you're actually getting is the projection of vector c onto just another vector, and the result is a proportion of the length of that vector.
If at first you don't succeed, redefine success.
furby100
furby100
The cross product can be used to find the distance between a point and a line, a normal vector to two other vectors, and the dot product and cross product can be used together in the "scalar triple product" to find the distance between two lines, the volume of a parallelepiped or a tetrahedron, or whether some vectors form a left or right handed set.
hplus0603
hplus0603
"angles" are basically an obsolete, 2D concept. Whenever you feel that you need Radians or whatever, you've probably lost some data somewhere that you were supposed to have preserved and used. The only exception MAY be when treating mouse input, which is inherently 2D.

Anyway, the dot product between A and B returns the length of A when projected onto B, scaled by the magnitude of B. The cross product of A and B returns the (signed) area of the parallelogram defined by A and B as sides, or, alternately, two times the (signed) area of the triangle defined by A and B as sides.

Just forget the "angle" parts. It'll just shackle your understanding of geometry (by which I probably mean higher-dimensional math).
enum Bool { True, False, FileNotFound };
atcdevil
atcdevil
Quote:
Original post by hplus0603
The cross product of A and B returns the (signed) area of the parallelogram defined by A and B as sides, or, alternately, two times the (signed) area of the triangle defined by A and B as sides.


Actually that is not the cross product. Just its magnitude. Not being able to understand the difference between a vector and a scalar will shackle your understanding of high school physics or something.


:P (just being silly, don't take it the wrong way)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.