Back to index

wims  3.65+svn20090927
pt.java
Go to the documentation of this file.
00001 // pt.java - 09/12/98
00002 
00003 package geo ;
00004 
00005 import java.awt.Graphics ;
00006 
00014 public class pt extends ObjetRepere
00015 {
00016 
00021   public int X, Y ;
00022 
00027   public double x ;
00028 
00033   public double y ;
00034 
00039   public pt (String Nom, Repere R)
00040   { super (Nom, R) ; }
00041 
00046   public pt (pt A, String Nom, Repere R)
00047   { super (Nom, R) ; X = A.X ; Y  = A.Y ;
00048     x = A.x ; y = A.y ;
00049     defini = A.defini ; }
00050 
00055   public pt (int X, int Y, String Nom, Repere R)
00056   { super (Nom, R) ; this.X = X ; this.Y = Y ;
00057     x = R.Abs (X) ; y = R.Ord (Y) ;
00058     defini = true ; }
00059 
00060 
00065   public pt (double x, double y, String Nom, Repere R)
00066   { super (Nom, R) ;
00067     this.x = x ; this.y = y ; 
00068     majXY () ; defini = true ; }
00069 
00074   public void majXY ()
00075   { X = R.Iabs (x) ; Y = R.Iord (y) ; }
00076 
00077 
00082   public void Milieu (pt A, pt B)
00083   { x = (A.x + B.x) / 2.0 ; y = (A.y + B.y) / 2.0 ;
00084     majXY () ;
00085     defini = A.defini && B.defini ; }
00086 
00091   public void Symetrique (pt A, pt C)
00092   { defini = A.defini && C.defini ;
00093     if (defini) { x = 2.0 * C.x - A.x ; y = 2.0 * C.y - A.y ; majXY () ; }
00094   }
00095 
00100    public void Rotation (pt A, pt O, double a)
00101    { defini = A.defini && O.defini ;
00102      if (defini) { double OAx = A.x - O.x ;
00103                    double OAy = A.y - O.y ;
00104                    double cosa = Math.cos (a) ;
00105                    double sina = Math.sin (a) ;
00106                    x = O.x + cosa * OAx - sina * OAy ;
00107                    y = O.y + sina * OAx + cosa * OAy ;
00108                    majXY () ;
00109                  }
00110    }
00111 
00116    public void Homothetique (pt A, pt O, double k)
00117    { defini = A.defini && O.defini ;
00118      if (defini) { x = O.x + k * (A.x - O.x) ;
00119                    y = O.y + k * (A.y - O.y) ;
00120                    majXY () ;
00121                  }
00122    }
00123 
00128    public double Distance (pt A)
00129    { if (defini && A.defini)
00130        { double dx = x - A.x ; double dy = y - A.y ;
00131          return Math.sqrt(dx * dx + dy * dy) ;
00132        }
00133      else return -1.0 ; }
00134 
00139   public boolean zone (int X, int Y)
00140   { return ((X >=  this.X - 2) && (X <= this.X + 2) && (Y >= this.Y - 2) && (Y <= this.Y + 2)) ; }
00141 
00146   public void trace (Graphics g)
00147   { if (defini) { g.fillRect (X - 1, Y - 1, 3, 3);
00148                   if (Nom.length () != 0) g.drawString (Nom, X + 3, Y - 3); } }
00149 
00154   public void traceNom (Graphics g)
00155   { if (defini && (Nom.length () != 0)) g.drawString (Nom, X + 3, Y - 3) ; }
00156 
00161   public void point (double x, double y)
00162   { this.x = x ; this.y = y ; majXY () ; defini = true ; }
00163 
00168   public void point ()
00169   { majXY () ; }
00170 
00171 }