|
From: <de...@us...> - 2003-09-02 08:56:45
|
Update of /cvsroot/fudaa/fudaa_devel/ebli/src/org/fudaa/ebli/geometrie
In directory sc8-pr-cvs1:/tmp/cvs-serv11587/org/fudaa/ebli/geometrie
Modified Files:
GrPoint.java GrSegment.java
Log Message:
Modif...
Index: GrPoint.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/ebli/src/org/fudaa/ebli/geometrie/GrPoint.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** GrPoint.java 4 Jul 2003 14:32:48 -0000 1.3
--- GrPoint.java 2 Sep 2003 08:56:17 -0000 1.4
***************
*** 48,51 ****
--- 48,56 ----
}
+ public GrPoint(Point _p){
+ x=_p.x;
+ y=_p.y;
+ }
+
public final void initialise(GrPoint _p)
{
Index: GrSegment.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/ebli/src/org/fudaa/ebli/geometrie/GrSegment.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** GrSegment.java 18 Mar 2003 16:14:16 -0000 1.2
--- GrSegment.java 2 Sep 2003 08:56:17 -0000 1.3
***************
*** 20,52 ****
* @author Guillaume Desnoix
*/
! public final class GrSegment
! extends GrObjet
! implements GrContour
! {
! public GrPoint o,e;
! public GrSegment()
! {
! }
! public GrSegment(GrPoint io, GrPoint ie)
! {
! o=io;
! e=ie;
}
! public GrVecteur vecteur()
! {
return e.soustraction(o);
}
! public final String toString()
! {
! return "GrSegment("+o+", "+e+")";
}
! public final GrPoint milieu()
! {
! return new GrPoint((o.x+e.x)/2., (o.y+e.y)/2., (o.z+e.z)/2.);
}
--- 20,43 ----
* @author Guillaume Desnoix
*/
! public final class GrSegment extends GrObjet implements GrContour {
! public GrPoint o, e;
! public GrSegment() {}
! public GrSegment(GrPoint io, GrPoint ie) {
! o= io;
! e= ie;
}
! public GrVecteur vecteur() {
return e.soustraction(o);
}
! public final String toString() {
! return "GrSegment(" + o + ", " + e + ")";
}
! public final GrPoint milieu() {
! return new GrPoint((o.x + e.x) / 2., (o.y + e.y) / 2., (o.z + e.z) / 2.);
}
***************
*** 54,72 ****
* Implémentation GrObjet.
*/
! public final GrBoite boite()
! {
! GrBoite r=new GrBoite();
! r.ajuste(o);
! r.ajuste(e);
return r;
}
! public final double longueurXY()
! {
return o.distanceXY(e);
}
! public final double longueur()
! {
return o.distance(e);
}
--- 45,86 ----
* Implémentation GrObjet.
*/
! public final GrBoite boite() {
! GrBoite r= new GrBoite();
! boite(r);
return r;
}
! /**
! * Initialise la boite passee en parametre a partir de la boite de
! * ce segment.
! */
! public final void boite(GrBoite _b) {
! if (_b.e == null)
! _b.e= new GrPoint(e);
! else
! _b.e.initialise(e);
! if (_b.o == null)
! _b.o= new GrPoint(e);
! else
! _b.o.initialise(e);
! if (o.x < e.x)
! _b.o.x= o.x;
! if (o.y < e.y)
! _b.o.y= o.y;
! if (o.z < e.z)
! _b.o.z= o.z;
! if (o.x > e.x)
! _b.e.x= o.x;
! if (o.y > e.y)
! _b.e.y= o.y;
! if (o.z > e.z)
! _b.e.z= o.z;
! }
!
! public final double longueurXY() {
return o.distanceXY(e);
}
! public final double longueur() {
return o.distance(e);
}
***************
*** 76,84 ****
* point le plus proche sur le segment pour le calcul de cette distance.
*/
! public final double distanceXY(GrPoint p)
! {
/*
double d=p.soustraction(o).projectionXY().division(vecteur().projectionXY());
!
if(d<=0.)
return o.distanceXY(p);
--- 90,97 ----
* point le plus proche sur le segment pour le calcul de cette distance.
*/
! public final double distanceXY(GrPoint p) {
/*
double d=p.soustraction(o).projectionXY().division(vecteur().projectionXY());
!
if(d<=0.)
return o.distanceXY(p);
***************
*** 96,105 ****
* proche sur le segment pour le calcul de cette distance.
*/
! public final double distance(GrPoint p)
! {
/*
double d=p.soustraction(o).division(vecteur());
double r;
!
if(d<=0.)
r=o.distance(p);
--- 109,117 ----
* proche sur le segment pour le calcul de cette distance.
*/
! public final double distance(GrPoint p) {
/*
double d=p.soustraction(o).division(vecteur());
double r;
!
if(d<=0.)
r=o.distance(p);
***************
*** 108,112 ****
else
r=o.addition(vecteur().multiplication(d)).distance(p);
!
return r;
*/
--- 120,124 ----
else
r=o.addition(vecteur().multiplication(d)).distance(p);
!
return r;
*/
***************
*** 119,133 ****
* du point donne.
*/
! public final GrPoint pointPlusProche(GrPoint p)
! {
! double d=p.soustraction(o).division(vecteur());
GrPoint r;
! if(d<=0.)
! r=new GrPoint(o.x,o.y,o.z);
! else if(d>=1.)
! r=new GrPoint(e.x,e.y,e.z);
else
! r=o.addition(vecteur().multiplication(d));
return r;
--- 131,144 ----
* du point donne.
*/
! public final GrPoint pointPlusProche(GrPoint p) {
! double d= p.soustraction(o).division(vecteur());
GrPoint r;
! if (d <= 0.)
! r= new GrPoint(o.x, o.y, o.z);
! else if (d >= 1.)
! r= new GrPoint(e.x, e.y, e.z);
else
! r= o.addition(vecteur().multiplication(d));
return r;
***************
*** 138,178 ****
* du point donne dans le plan x,y.
*/
! public final GrPoint pointPlusProcheXY(GrPoint p)
! {
! double d=p.soustraction(o).projectionXY().division(vecteur().projectionXY());
GrPoint r;
! if(d<=0.)
! r=new GrPoint(o.x,o.y,o.z);
! else if(d>=1.)
! r=new GrPoint(e.x,e.y,e.z);
else
! r=o.addition(vecteur().multiplication(d));
! r.z=0.;
return r;
}
! public final GrPoint intersectionXY(GrSegment s)
! {
! if(boite().intersectionXY(s.boite())==null) return null;
! GrVecteur txy=vecteur().projectionXY();
! GrVecteur sxy=s.vecteur().projectionXY();
! GrVecteur n=txy.produitVectoriel(sxy);
! if( ( s.o.soustraction(o).projectionXY().produitTripleScalaire(txy,n)
! * s.e.soustraction(o).projectionXY().produitTripleScalaire(txy,n) <0)
! &&( o.soustraction(s.o).projectionXY().produitTripleScalaire(sxy,n)
! * e.soustraction(s.o).projectionXY().produitTripleScalaire(sxy,n) <0))
! {
! double t=o.soustraction(s.o).projectionXY().produitTripleScalaire(txy,n)
! /sxy.produitTripleScalaire(txy,n);
! GrPoint p=s.o.addition(sxy.multiplication(t));
! p.z=0.;
return p;
! }
! else return null;
}
--- 149,191 ----
* du point donne dans le plan x,y.
*/
! public final GrPoint pointPlusProcheXY(GrPoint p) {
! double d=
! p.soustraction(o).projectionXY().division(vecteur().projectionXY());
GrPoint r;
! if (d <= 0.)
! r= new GrPoint(o.x, o.y, o.z);
! else if (d >= 1.)
! r= new GrPoint(e.x, e.y, e.z);
else
! r= o.addition(vecteur().multiplication(d));
! r.z= 0.;
return r;
}
! public final GrPoint intersectionXY(GrSegment s) {
! if (boite().intersectionXY(s.boite()) == null)
! return null;
! GrVecteur txy= vecteur().projectionXY();
! GrVecteur sxy= s.vecteur().projectionXY();
! GrVecteur n= txy.produitVectoriel(sxy);
! if ((s.o.soustraction(o).projectionXY().produitTripleScalaire(txy, n)
! * s.e.soustraction(o).projectionXY().produitTripleScalaire(txy, n)
! < 0)
! && (o.soustraction(s.o).projectionXY().produitTripleScalaire(sxy, n)
! * e.soustraction(s.o).projectionXY().produitTripleScalaire(sxy, n)
! < 0)) {
! double t=
! o.soustraction(s.o).projectionXY().produitTripleScalaire(txy, n)
! / sxy.produitTripleScalaire(txy, n);
! GrPoint p= s.o.addition(sxy.multiplication(t));
! p.z= 0.;
return p;
! } else
! return null;
}
***************
*** 180,211 ****
* Retourne le segment le plus court joignant deux segments.
*/
! public final GrSegment segmentPlusCourtXY(GrSegment s)
! {
! GrSegment r=null;
! GrPoint i=intersectionXY(s);
! if(i!=null)
! {
! r=new GrSegment(i,i);
! }
! else
! {
! GrPoint p;
GrSegment t;
! p=pointPlusProcheXY(s.o); // p E this
! r=new GrSegment(p,s.o);
! p=pointPlusProcheXY(s.e); // p E this
! t=new GrSegment(p,s.e);
! if(t.longueurXY()<r.longueurXY()) r=t;
! p=s.pointPlusProcheXY(o); // p E s
! t=new GrSegment(p,o);
! if(t.longueurXY()<r.longueurXY()) r=t;
! p=s.pointPlusProcheXY(e); // p E s
! t=new GrSegment(p,e);
! if(t.longueurXY()<r.longueurXY()) r=t;
}
--- 193,223 ----
* Retourne le segment le plus court joignant deux segments.
*/
! public final GrSegment segmentPlusCourtXY(GrSegment s) {
! GrSegment r= null;
! GrPoint i= intersectionXY(s);
! if (i != null) {
! r= new GrSegment(i, i);
! } else {
! GrPoint p;
GrSegment t;
! p= pointPlusProcheXY(s.o); // p E this
! r= new GrSegment(p, s.o);
! p= pointPlusProcheXY(s.e); // p E this
! t= new GrSegment(p, s.e);
! if (t.longueurXY() < r.longueurXY())
! r= t;
! p= s.pointPlusProcheXY(o); // p E s
! t= new GrSegment(p, o);
! if (t.longueurXY() < r.longueurXY())
! r= t;
! p= s.pointPlusProcheXY(e); // p E s
! t= new GrSegment(p, e);
! if (t.longueurXY() < r.longueurXY())
! r= t;
}
***************
*** 213,255 ****
}
! public final GrSegment applique(GrMorphisme t)
! {
! GrSegment res=new GrSegment();
! res.o=o.applique(t);
! res.e=e.applique(t);
return res;
}
! public final void autoApplique(GrMorphisme t)
! {
o.autoApplique(t);
e.autoApplique(t);
}
! /*
! public GrPoint intersection(GrSegment s)
! {
! if(boite().intersection(s.boite())==null) return null;
!
! GrVecteur n=vecteur().produitVectoriel(s.vecteur());
!
! if( ( s.o.soustraction(o).produitTripleScalaire(vecteur(),n)
! * s.e.soustraction(o).produitTripleScalaire(vecteur(),n) <0)
! &&( o.soustraction(s.o).produitTripleScalaire(s.vecteur(),n)
! * e.soustraction(s.o).produitTripleScalaire(s.vecteur(),n) <0))
{
! double t=o.soustraction(s.o).produitTripleScalaire(vecteur(),n)
! /s.vecteur().produitTripleScalaire(vecteur(),n);
!
! return s.o.addition(s.vecteur().multiplication(t));
}
! else return null;
! }
! */
!
! public final GrPoint[] contour()
! {
! return new GrPoint[] { o,e };
}
--- 225,263 ----
}
! public final GrSegment applique(GrMorphisme t) {
! GrSegment res= new GrSegment();
! res.o= o.applique(t);
! res.e= e.applique(t);
return res;
}
! public final void autoApplique(GrMorphisme t) {
o.autoApplique(t);
e.autoApplique(t);
}
! /*
! public GrPoint intersection(GrSegment s)
{
! if(boite().intersection(s.boite())==null) return null;
!
! GrVecteur n=vecteur().produitVectoriel(s.vecteur());
!
! if( ( s.o.soustraction(o).produitTripleScalaire(vecteur(),n)
! * s.e.soustraction(o).produitTripleScalaire(vecteur(),n) <0)
! &&( o.soustraction(s.o).produitTripleScalaire(s.vecteur(),n)
! * e.soustraction(s.o).produitTripleScalaire(s.vecteur(),n) <0))
! {
! double t=o.soustraction(s.o).produitTripleScalaire(vecteur(),n)
! /s.vecteur().produitTripleScalaire(vecteur(),n);
!
! return s.o.addition(s.vecteur().multiplication(t));
! }
! else return null;
}
! */
! public final GrPoint[] contour() {
! return new GrPoint[] { o, e };
}
***************
*** 263,272 ****
* @author b.marchand Le 26/10/2000
*/
! public final boolean estSelectionne(GrMorphisme _ecran, int _dist, Point _pt) {
! GrPolyligne pl=new GrPolyligne();
! pl.sommets.ajoute(o);
! pl.sommets.ajoute(e);
! return pl.estSelectionne(_ecran,_dist,_pt);
}
}
--- 271,291 ----
* @author b.marchand Le 26/10/2000
*/
! public final boolean estSelectionne(
! GrMorphisme _ecran,
! int _dist,
! Point _pt) {
! return estSelectionne(_ecran, _dist, new GrPoint(_pt));
! }
! public final boolean estSelectionne(
! GrMorphisme _ecran,
! int _dist,
! GrPoint _pt) {
! GrSegment p= applique(_ecran);
! return p.distanceXY(_pt) < _dist;
! }
!
! public final boolean estSelectionne(int _dist, GrPoint _pt) {
! return distanceXY(_pt) < _dist;
}
}
|