# What does -1.#IND mean?

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

## Recommended Posts

When I print out a float to screen, that is supposed to be the degrees in radians between two vectors, I get -1.#IND, what could it mean? I thought maybe it means that the function that I used to compute it returned an imaginary number and thats how its displaying it, I couldn't find anything online on it. Thnx for replies.

##### Share on other sites
It means you've done something unlegal with the float, most likely there's a divide by zero you're missing somewhere. If you post the code (both calculating the angle as well as printing), we can help catch it and suggest a safer alternative.

-jouley

[Edit: Actually, dividing by zero yields a "1.#INF" error (emphasis mine). This points out that "1.#IND" is caused by trying to performing trigonometric operations on a number that's out of range (like acos(2.3f)).]

[Edit 2: Actually, dividing zero by zero yields a "-1.#IND" error (thanks, miodragsm!). My money's still on an illegal trig operation, though.]

##### Share on other sites
This means that the variable is not a number (NaN). This could be caused by using an unitialized variable or possibly dividing by zero.

##### Share on other sites
It's 0.0f/0.0f result. Try this :

float a=0,b=0;
float c=a/b;

I tried this in VC8 and got -1.#IND000.

##### Share on other sites
This is the parts of the source that I use to compue the angle between 2 vects.
Like Mr.Awesome said theres the value procuced for acos() is probably greater than 1.

BALL_angle += MXMATH::AngleBetweenVectors(spherePoint, nowPoint);float MXMATH::AngleBetweenVectors(D3DXVECTOR3  v1, D3DXVECTOR3  v2){	return (float)(acos( (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z)/(Vect3DLength(v1)*Vect3DLength(v2)) ));}float MXMATH::Vect3DLength(D3DXVECTOR3 v){	return (float)sqrt( sqr(v.x) + sqr(v.y) + sqr(v.z) );}

##### Share on other sites
You should probably check that your argument to acos is in the interval [-1, 1]. Even a small amount outside this range will cause a NaN.

##### Share on other sites
You may want to look into the atan2(float y, float x) function. It'll get the quadrant correct for you, and can take any sort of input (except (0, 0)).
Usage, where point1 = x1, y1 and point2 = x2, y2:float fAngle = atan2(y2 - y1, x2 - x1);

##### Share on other sites
You can also get it by square rooting a negative number, but that shouldn't be happening in the code you posted.

##### Share on other sites
Thanks for replies guys, I appreciate the help. Im just gonna check the input for acos() to make sure its not greater than 1 or less than -1. Thanks again.

##### Share on other sites
Quote:
 Original post by VanillaSnake21Thanks for replies guys, I appreciate the help. Im just gonna check the input for acos() to make sure its not greater than 1 or less than -1. Thanks again.

Don't do that. At values close to 1 or -1, even those which don't look out of range, strange things can happen. acos is not a good way to find the angle between vectors.

For 3D vectors, the best way is atan2(dot(v1,v2), magnitude(cross(v1,v2))). This is robust and well-behaved under all circumstances.

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 9
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632920
• Total Posts
3009209
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!