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

Dot product

Started by Alex2 Jan 19, 2002 at 7:18 AM 2 replies 300+ views
Original Post
Alex2
Alex2
I must have missed something, cause I have read a lot of explanations of it, but I still don''t understand it''s use. What is dot product and what is it for? Thanks in advance!
BSXrider
BSXrider
The dot product is very useful in a million different ways.

Suppose you have two vectors A and B.

A = (Ax,Ay,Az)
B = (Bx,By,Bz)

A.B = AxBx + AyBy + AzBz = |A||B|cos(theta)

So the dot product of two vectors A and B is equal to the product of the magnitudes time the cosine of the angle between the vectors.

The useful part here is the angle. so we get:

theta = inverse cosine ( A.B / |A||B| )

A.B you work out as above (AxBx + AyBy + AzBz)
|A| is sqrt(AxAx+AyAy+AzAz)
|B| is sqrt(BxBx+ByBy+BzBz)

so all that is unknown is theta and can be calculated.

I hope some of that makes sense.

- seb
BSXrider
BSXrider
But I think you understood all that anyway :I

To answer your question of what is it used for.

Well, to find the angle between two vectors. Why would you want to do this? Collision detection, lighting and again a million other things.

- seb
MindWipe
MindWipe
Thanks!

I havn''t really figured out how good vectors really are. And I didn''t really get the dot product.

But now I do

Thanks

/MindWipe

"If it doesn''t fit, force it; if it breaks, it needed replacement anyway."
"To some its a six-pack, to me it's a support group."

Topic Locked

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

Sign in to reply to this topic.