01 /**
02 * Une classe de test pour Orbite.
03 *
04 * @author <a href="mailto:garion@isae.fr">Christophe Garion</a>
05 * @version 1.0
06 */
07 public class TestOrbite {
08
09 /**
10 * Programme de test pour la classe <code>Orbite</code>.
11 *
12 * @param args non utilise ici
13 */
14 public static void main(String[] args) {
15 Orbite gps = new Orbite(0.0, 26E6);
16 Orbite exosat = new Orbite(0.93, 100E6);
17
18 testEgalite(26E6, gps.getB(), "Test b pour GPS");
19 testEgalite(36755951.898978, exosat.getB(), "Test b pour EXOSAT");
20
21 double c = gps.getC();
22
23 double distance = 2 * (gps.getA() - c) + 2 * c;
24
25 Point foyer1 = gps.getFoyer();
26 Point foyer2 = new Point(foyer1.getX() - 2 * c, foyer1.getY());
27
28 Point p = null;
29
30 for (double theta = 0; theta < 2 * Math.PI; theta += 10E-6) {
31 p = gps.calculerPointSurOrbite(theta);
32 testEgalite(distance, p.distance(foyer1) + p.distance(foyer2),
33 "Test orbite GPS avec angle " + theta);
34 }
35
36 c = exosat.getC();
37
38 distance = 2 * (exosat.getA() - c) + 2 * c;
39
40 foyer1 = exosat.getFoyer();
41 foyer2 = new Point(foyer1.getX() - 2 * c, foyer1.getY());
42
43 for (double theta = 0; theta < 2 * Math.PI; theta += 10E-6) {
44 p = exosat.calculerPointSurOrbite(theta);
45 testEgalite(distance, p.distance(foyer1) + p.distance(foyer2),
46 "Test orbite EXOSAT avec angle " + theta);
47 }
48
49 Point vec = null;
50
51 for (double v = 0; v < 2 * Math.PI; v += 1E-5) {
52 p = gps.calculerPointSurOrbiteFoyer(v);
53 distance = p.distance(new Point(0.0, 0.0));
54
55 p.setX(p.getX() / distance);
56 p.setY(p.getY() / distance);
57
58 vec = gps.calculerVecteurTangent(v);
59
60 testEgalite(0.0, p.getX() * vec.getX() + p.getY() * vec.getY(),
61 "Test vecteur tangent orbite GPS avec angle " + v);
62 }
63 }
64
65 private static void testEgalite(double attendu, double reel, String message) {
66 System.out.print(message + " : ");
67
68 if (Math.abs(attendu - reel) < Orbite.EPS) {
69 System.out.println("OK");
70 } else {
71 System.out.println("ERREUR! attendu : " + attendu + ", obtenu : " + reel);
72 }
73 }
74 }
|