|
-
September 26th, 2008, 04:43 AM
#1
acos returns -1.#IND
hello guys,
in my program, i need to get the angle between two normals.
i first get the dot product of the two normals and use acos to get the actual angle.
the code is rather simple like this:
float dot=Math: ot(normal1,normal2);
printf("dot in2:%f\n",dot);
angle=acos(dot);
printf("angle1:%f\n",angle);
i got the output:
dot in2:1.000000
angle1:-1.#IND00
the weird thing is that the infinite result doesn't always happen when the dot is 1.000000. for example, one of the outputs was:
dot in2:1.000000
angle1:0.000598
so i guess the float is rounded when being outputted.
although in both cases, the dot values are 1, i guess they are not.
and i also tried acos(1), the result is 0, not -1.#IND
now i'm wondering, is that true the function acos can return -1.#IND.
how can i avoid that?
thank you.
-
September 26th, 2008, 04:47 AM
#2
Re: acos returns -1.#IND
i guess i know the answer,
i tried acos(1.00020001f), the result was -1.#INF
-
September 26th, 2008, 07:40 AM
#3
Re: acos returns -1.#IND
Yeah, you need to clamp the value to the range [-1,1].
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|