Add this to your code to see what you are passing to acos():
System.out.println("acos arg=" + a*(180/3.14)); // show the arg
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
I was trying to show you that your arg to acos() was > 1 which will return a NaN value.
For example this code passes args to acos from .1 to 1.1:
for(double a = .1; a < 1.1; a+= .1) {
double b = Math.acos(a);
System.out.println ("a=" + a + ", b=" + b);
}
/*
a=0.1, b=1.4706289056333368
a=0.2, b=1.369438406004566
a=0.30000000000000004, b=1.266103672779499
a=0.4, b=1.1592794807274085
a=0.5, b=1.0471975511965979
a=0.6, b=0.9272952180016123
a=0.7, b=0.7953988301841436
a=0.7999999999999999, b=0.6435011087932845
a=0.8999999999999999, b=0.45102681179626264
a=0.9999999999999999, b=1.4901161193847656E-8
a=1.0999999999999999, b=NaN
*/
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
I guess you need to read the API doc for the acos method.
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656