I have some code that will allow me to draw a crescent moon shape, and have extracted the values to excel to be drawn. However in place of some numbers, there is -1.#IND
in place. Firstly if anyone could explain what this means, as Google came back with 0 links. And secondly if there is anyway to stop it from occurring.
There is a brief analogy of my code. I have lots more code besides this, however that is just calculating angles.
for(int j=0; j<=n; j++)//calculation for angles and output displayed to user
{
Xnew2 = -j*(Y+R1)/n; //calculate x coordinate
Ynew2 = Y*(pow(1-(pow((Xnew2/X),2)),0.5));
if(abs(Ynew2) <= R1)
cout<<"\n("<<Xnew2<<", "<<Ynew2<<")"<<endl;
}
MORE INFO
I'm now having the problem with this code.
for(int i=0; i<=n; i++) //calculation for angles and output displayed to user
{
Xnew = -i*(Y+R1)/n; //calculate x coordinate
Ynew = pow((((Y+R1)*(Y+R1)) - (Xnew*Xnew)), 0.5); //calculate y coordinate
AND
for(int j=0; j<=n; j++)//calculation for angles and output displayed to user
{
Xnew2 = -j*(Y+R1)/((n)+((0.00001)*(n==0))); //calculate x coordinate
Ynew2 = Y*(pow(abs(1-(pow((Xnew2/X),2))),0.5));
if(abs(Ynew2) <= R1)
cout<<"\n("<<Xnew2<<", "<<Ynew2<<")"<<endl;
I am having the problem drawing the crescent moon that I cannot get the two circles to have the same starting point? If this makes sense, I am trying to get two parts of circles to draw a crescent moon as such that they have the same start and end points. The only user input I have to work by is the radius and chosen center point.
If anyone has any suggestions on how to do this, it would be great, currently all I am getting more a 'half doughnut' shape, due to the circles not being connected.
#IND
means an indetermined form.
What you have there is something known as 'Not a number'
or NaN for short.
Quoting from Wikipedia, generation is done by:
- Operations with a NaN as at least one operand.
- The divisions 0/0 and ±∞/±∞
- The multiplications 0×±∞ and ±∞×0
- The additions ∞ + (−∞), (−∞) + ∞ and equivalent subtractions
- The square root of a negative number.
- The logarithm of a negative number
- The inverse sine or cosine of a number that is less than −1 or greater than +1.
You're doing at least one of those things.
Edit:
After analyzing your code, these are 2 possibilities:
n == 0
in the first iteration where j == 0
too, Xnew2
will be -1.#IND
Xnew2
is greater than X
, Ynew2
will be complex -> NaN
You are doing something illegal to a floating point number, such as taking the square root of a negative number. This is presumably on Windows. On Linux, you would get NaN (not a number) or inf. See -1 #IND Question for further information; the link provided in the second answer is helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With