added a protection against infinite loops that occur with some JVM (Sun before 1.4, JRockit, ...)
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@799849 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
253c7d3b94
commit
f7730c09f2
|
@ -104,8 +104,8 @@ public class TestProblem3
|
||||||
// solve Kepler's equation
|
// solve Kepler's equation
|
||||||
double E = t;
|
double E = t;
|
||||||
double d = 0;
|
double d = 0;
|
||||||
double corr = 0;
|
double corr = 999.0;
|
||||||
do {
|
for (int i = 0; (i < 50) && (Math.abs(corr) > 1.0e-12); ++i) {
|
||||||
double f2 = e * Math.sin(E);
|
double f2 = e * Math.sin(E);
|
||||||
double f0 = d - f2;
|
double f0 = d - f2;
|
||||||
double f1 = 1 - e * Math.cos(E);
|
double f1 = 1 - e * Math.cos(E);
|
||||||
|
@ -113,7 +113,7 @@ public class TestProblem3
|
||||||
corr = f0 * f12 / (f1 * f12 - f0 * f2);
|
corr = f0 * f12 / (f1 * f12 - f0 * f2);
|
||||||
d -= corr;
|
d -= corr;
|
||||||
E = t + d;
|
E = t + d;
|
||||||
} while (Math.abs(corr) > 1.0e-12);
|
};
|
||||||
|
|
||||||
double cosE = Math.cos(E);
|
double cosE = Math.cos(E);
|
||||||
double sinE = Math.sin(E);
|
double sinE = Math.sin(E);
|
||||||
|
|
Loading…
Reference in New Issue