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

why doesn't my D3DXVec3Dot(...) equal 1.57..?

Started by mickey Oct 21, 2002 at 11:37 AM 6 replies 2k views
Original Post
mickey
mickey
hiya, D3DXVECTOR3 v1(1.0f, 0.0f, 0.0f); D3DXVECTOR3 v2(0.0f, 1.0f, 0.0f); float answer = D3DXVec3Dot(&v1, &v2); why does answer equals zero? also, am doing that to check for collision, is that okey? many thanks, [edited by - mickey on October 21, 2002 12:42:08 PM]
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
niyaw
niyaw
you''re taking a dot product of two perpendicular vectors, which will always be zero. to find a magnitude of the sum of the vectors, which is what you seem to be after, use sqrt(d3dxvec3lengthsq(&v1)+d3dxvec3lengthsq(&v2)).
mickey
mickey
eh i''d really like to know why isn''t the answer 90 degrees since dot product gives us the angle?
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
HunterTKilla
HunterTKilla
Using Dot Product Here Are The Results:
Result < 0 = Acute Angle (<90 Degree)
Result > 0 = Obtuse Angle (>90 Degree)
Result = 0 = Perpendicular (90 Degree)
mickey
mickey
i always come across ''the dot product of two vectors can give us the angle in between'' shoot, i didn''t realize that the result(dot product) of this is what will help us to get the angle. all along i thought the dot product was the angle!

hehe thanks guys!
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
Nypyren
Nypyren
Let's see... isn't it...

A.Dot(B) == A.Length() * B.Length() * cos(angle_between_them)

?

If that's true, then:

angle = acos(A.Dot(B) / (A.Length()*B.Length()) );


... I think.

[edited by - Nypyren on October 22, 2002 3:28:57 AM]
mickey
mickey
uh did i get this thing right... this method of getting the dot product is not useful? dot = v1 * v2 = (vx1 * vx2) + (vy1 * vy2) ? we should be using the other method which nypyren said?

also, do i have to normalized the vector before getting their dot product because the dot product should only be between -1.0 to +1.0?

thanks,
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,

Topic Locked

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

Sign in to reply to this topic.