Back to index

wims  3.65+svn20090927
PointSurCercle.java
Go to the documentation of this file.
00001 package geo ;
00002 
00009 public class PointSurCercle extends pointlibre
00010 { public double a;
00011   public Cercle c;
00012 
00017   public PointSurCercle (double a, Cercle c, String Nom, Repere R)
00018   { super (c.xo + c.r * Math.cos (a), c.yo + c.r * Math.sin (a), Nom, R);
00019     this.c = c ; defini = c.defini ;
00020     this.a = a % (Math.PI * 2) ; if (this.a > Math.PI) this.a = this.a - 2.0 * Math.PI ;
00021   }
00022 
00027   public PointSurCercle (int X, int Y, Cercle c, String Nom, Repere R)
00028   { super (R.Abs (X), R.Ord (Y), Nom, R) ;
00029     defini = c.defini ; this.c = c ;
00030     if (defini) a = calcule (X, Y, c) ; else a = 0.0 ;
00031   }
00032 
00033 
00034   private double calcule (int X, int Y, Cercle c)
00035   { double dx, dy ;
00036     dx = X - R.Iabs (c.xo) ;
00037     dy = R.Iord (c.yo) - Y ;
00038     if (dx != 0.0) a = Math.atan (dy / dx) ;
00039       else { a = Math.PI / 2 ; if (dy < 0) a = - a ; }
00040     if (dx < 0) a = a + Math.PI ;
00041    if (a > Math.PI) a = a - 2.0 * Math.PI ;
00042    return a ;
00043   }
00044 
00050   public void bouge (int X, int Y)
00051   { if (deplace && defini && R.affiche (X, Y)) { Xp = this.X ; Yp = this.Y ;
00052                                                  a = calcule (X, Y, c) ;
00053                                                  x = c.xo + c.r * Math.cos (a) ;
00054                                                  y = c.yo + c.r * Math.sin (a) ;
00055                                                  this.X = R.Iabs (x) ; this.Y = R.Iord (y) ;
00056                                                }
00057   }
00058 
00063   public void point ()
00064   { x = c.xo + c.r * Math.cos (a) ; y = c.yo + c.r * Math.sin (a) ;
00065     Xp = X = R.Iabs (x) ; Yp = Y = R.Iord (y) ; 
00066     defini = c.defini; }                   
00067 
00068 }