Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

boomji

dot product and it's derivation

This topic is 5347 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, googled around first but did not find what i was looking for. any way,could any one tell me why is the dot product ||A||*||B||cos theta. Every where i read up this was a given(cos theta). now i know i may not yet be abel to digest the proof even if it was explained but i''m hoping some one could post a visual explanation or point me to one...please. thanks for your time. b

Share this post


Link to post
Share on other sites
Advertisement
The definition of the dot product for two vectors and is Ax*Bx + Ay*By. Also, Aθ is arctan(Ay/Ax) and Bθ is arctan(By/Bx). SO:

dot(A,B) = Ax*Bx + Ay*By
= ||A||cos(Aθ ) * ||B||cos(Bθ ) + ||A||sin(Aθ ) * ||B||sin(Bθ )

= ||A|| * ||B|| * cos(Aθ ) * cos(Bθ ) + ||A|| * ||B|| * sin(Aθ ) * sin(Bθ )

= (||A|| * ||B||)(cos(Aθ ) * cos(Bθ ) + sin(Aθ ) * sin(Bθ ))

and, by some product-to-sum trig identities:

= (||A|| * ||B||)((1/2 * cos(Aθ - Bθ ) + cos(Aθ + Bθ ))+(1/2 * cos(Aθ - Bθ ) - cos(Aθ + Bθ )))

= (||A|| * ||B||) * 1/2 * (cos(Aθ - Bθ ) + cos(Aθ + Bθ )+cos(Aθ - Bθ ) - cos(Aθ + Bθ ))

= (||A|| * ||B||) * 1/2 * (cos(Aθ - Bθ )+cos(Aθ - Bθ ))

= (||A|| * ||B||) * cos(Aθ - Bθ )

TADA!



How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
Let''s do it backwards.

Let''s say you have 2 vectors in 3D, and you want to find |A|*|B|*cos theta. Does this reduce to Ax * Bx + Ay * By + Az * Bz? Let''s see.

|B|*cos theta is the length of the projection of vector B onto vector A. Let''s find the point on vector A of this projection.

Let''s call the coordinates of this point (Cx, Cy, Cz).

Now, let''s create a plane that has its normal as vector A - and let''s set this plane to intersect with the endpoint of vector B. The intersection of this plane with vector A will yield (Cx, Cy, Cz)!

This plane is:
Ax * x + Ay * y + Az * z = K, where K is some constant

Now, this plane must intersect with (Bx, By, Bz) as stated above.

Ax * Bx + Ay * By + Az * Bz = K

So the equation of the plane is:

Ax * x + Ay * y + Az * z = Ax * Bx + Ay * By + Az * Bz

Let''s find out how far this plane is along vector A.

Let''s represent vector A as a parametric line:

x = Ax * t / |A|
y = Ay * t / |A|
z = Az * t / |A|

We must divide by |A| in order to make t the actual distance along vector A. (i.e. an increment of 1 in t travels 1 unit)

Sub that in to the plane:

Ax * Ax * t / |A| + Ay * Ay * t / |A| + Az * Az * t / |A| = Ax * Bx + Ay * By + Az * Bz

Ax^2 * t / |A| + Ay^2 * t / |A| + Az^2 * t / |A| = Ax * Bx + Ay * By + Az * Bz

Ax^2 * t + Ay^2 * t + Az^2 * t = |A| * (Ax * Bx + Ay * By + Az * Bz)

Since Ax^2 + Ay^2 + Az^2 = |A|^2:

|A|^2 * t = |A| * (Ax * Bx + Ay * By + Az * Bz)

t = (Ax * Bx + Ay * By + Az * Bz)/|A|

Since t is the distance along vector A of the projection of vector B, t = |B| * cos theta

Therefore:

|A| * |B| * cos theta

= |A| * t

= |A| * (Ax * Bx + Ay * By + Az * Bz)/|A|

= Ax * Bx + Ay * By + Az * Bz

Wow ... that actually worked!

Share this post


Link to post
Share on other sites
Take A = |A|*a, B = |B|*b so that the vectors a=(ax,ay) and b=(bx,by) are unit vectors.

1) I think the factors |A| and |B| are clear then (put it into the equations if you don´t believe it, also the scalar product is bilinear by definition).

2) a*b is the projection of vector a on vector b (which happenes to be the same as the projection of b on a). Let both a and b lie in the xy-plane and let b be a unit vector in the x-direction (you might want to think about why/if that assumption is ok in a general case after you understood the following).
Draw both vectors in your coordinate system. Draw a triangle with points (0,0), (ax, ay), (ax, 0) which is a recangular triangle (vector (ax,0) is the projection of a on b as you will see).
By the geometrical definition of cos you´ll see that cos(theta) = |(ax,0)|/|(ax,ay)| = |projection(a -> b)|/1 = a*b.

EDIT: The |(ax,0)| above is not completely correct since it can also be negative when a is in the 2nd or 3rd quadrant but you´ll see from your picture what I meant.

[edited by - Atheist on October 22, 2003 2:56:34 AM]

Share this post


Link to post
Share on other sites
Actually guys, the dot product between 2 vectors A, B is DEFINED as |A||B|cos theta. Most people (mistakingly) get it the wrong way round, A.xB.x + A.yB.y + A.zB.z is NOT the definition of the dot product, it is merely a reduction of the definition into component form. The reduction is just an easier way of computing the dot product, and it follows from several different methods of reduction: one of which is Tron3k''s reduction.

Here is another reduction which I found interesting and in my opinion more visually and mathematically intuitive.

(1) A.B = |A||B|cos(theta) (by defn of dot product)

If you think of the length of the 3 vectors |A|,|B| and |B-A| as the lengths of the sides of a triangle, you can apply the law of cosines here too (boomji, to visualize this, draw the 2 vectors A and B onto a graph, now the vector from A to B will be given by B-A. The triangle formed by these 3 vectors is applied to the law of cosines for a triangle :D)
c^2 = a^2 + b^2 - 2.a.b.cos(C)
In this case, we substitute: |B-A| for c, |A| for a, |B| for b
and we obtain:

(2) |B-A|^2 = |A|^2 + |B|^2 - 2 |A|.|B|.cos(Theta) (by law of cosines)

Remember now, that Theta is the angle between the 2 vectors A, B.
Notice the common term |A||B|cos(Theta) in both equations. We now equate equation (1) and (2), and obtain

A.B = (-(|B-A|^2) + |A|^2 + |B|^2) / 2
and hence
A.B = (-((B.x^2 - 2A.xB.x + A.x^2) + (B.y^2 - 2A.yB.y + A.y^2) + (B.z^2 - 2A.zB.z + A.z^2)) + A.x^2 + A.y^2 + A.z^2 + B.x^2 + B.y^2 + B.z^2) / 2
(by pythagorean length of a vector) and thus
A.B = A.xB.x + A.yB.y + A.zB.z

This one I think is more visually explainable. Unfortunately, I don''t have the time to draw a diagram, sorry!

Hope this helped!


Share this post


Link to post
Share on other sites
Where did you get that way of definition (and what makes you think your source is THE definition)? I always thought the dot product is a special scalar product which is (in the form I know) given as a multilinear positive definite symmetric form over a vector space.
Also if the two forms are equal (which is only true in the case of a real vector space because you can´t define an angle in general) where is the point in marking one form as THE definition?

Share this post


Link to post
Share on other sites


hi there,
thanks so much folks...and pretty detailed as well.
the cosine rule and it's involvement here has made most of the cogs in my block head turn so i will definately look into that area more(did not do math beyound 10th grade...came right back at me and bit me in the moon there didn't it ).
thanks a ton guys...going to save this page and thoroughly go through it.

b

[edited by - boomji on October 22, 2003 1:51:18 PM]

Share this post


Link to post
Share on other sites
Hey Athiest, don''t be mistaken - the idea that that is the definition of dot-product is not just simply an idea that popped into my head. It was an idea strictly enforced by the mathematics academics whilst I was doing my degree. More generally, though the definition pertains to Euclidean space rather than Inner-product spaces.Sorry to have made such a broad statement - I guess that''s just asking for trouble (even if I am right :D) ... but by all means, prove me wrong

The point of proper definitions: learning and common language, although in this case they may clear up confusion of certain concepts. Such as the origin of the projection of a vector onto another vector, which has it''s basis in geometric and trigonometric methods and which is more easily explained by the definition |A||B|cosC of the dot product.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!