Hi,

I am trying to find the angle between two vectors. This

is going to be between -pi and pi and positive for counterclockwise

angles.

Using dot product I seem to get the correct results but I can't

interpret

the result for the cross product. Can someone help?

I attach a snippet and some explanation below.

--------------------------------------------------------------------

v1 = [0.0023 -0.0439];

v2 = [1 0];

v1_3D = [v1 0];

v2_3D = [v2 0];

CP = cross(v2_3D, v1_3D); % order matters: rotate v2 to v1

sign = 1;

if CP(3) < 0 % clockwise acute angle

sign = -1;

end

angleDot = sign*acos( dot(v1,v2)/(norm(v1)*norm(v2)) )

angleCross = sign*acos( norm(CP)/(norm(v1_3D)*norm(v2_3D)) )

--------------------------------------------------------------------

Now: acos(dot(v1,v2)/(norm(v1)*norm(v2))) -> 1.5185 which seems to be

the correct angle (without the sign)

However,

acos( norm(CP)/(norm(v1_3D)*norm(v2_3D)) ) -> 0.0523, that appear to

be

pi/2 - 1.5185.

Does anyone know why this happens? I expected them to give the same

result.

thanks

michalis

Computing the angle from the dot product goes, according to

my maths book,

cos(angle) = | a dot b | / |a||b|

while computing the angle from the cross product goes, according to

the same maths book, as

sin(angle) = | a cross b | / |a||b|.

HTH.

Rune

> Computing the angle from the dot product goes, according to

Of course you are right!!

That is absolutely my mistake!

Thanks for the help!

michalis

Of course you are right!!

That is absolutely my mistake!

Thanks for the help!

michalis

1. The dot product and cross product

2. Fastest way to compute dot product (inner product) in Ruby?

3. Dot and Cross products for Complex Numbers

4. Mapping Quote Product to Order Product to Invoice Product

5. Director - Product Management- Montreal - 2 Positions - 1 - B2B Products - 1 - B2C Products

8. Excel vs. calculator multiplication product discrepancy...

9. Is there an easy way to do a dot-product or cross-product function (matrix algebra) in Excel?

10. saving the product id not the product

11. Convert numbers to text (from product id # to name of product)

12. I need a product key for my Trail product, 2007 Microsoft Office s

13. Need Help with a Sum of a Product of a Currency and Product

14. Matching Product Key with product ID

3 post • Page:**1** of **1**