Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.jts / src / main / java / org / gvsig / fmap / geom / jts / util / UtilFunctions.java @ 42267

History | View | Annotate | Download (18.9 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.jts.util;
25

    
26
import java.awt.geom.Arc2D;
27
import java.awt.geom.Line2D;
28
import java.awt.geom.Point2D;
29
import java.awt.geom.Rectangle2D;
30

    
31
import org.slf4j.Logger;
32
import org.slf4j.LoggerFactory;
33

    
34
import org.gvsig.fmap.geom.Geometry;
35
import org.gvsig.fmap.geom.GeometryLocator;
36
import org.gvsig.fmap.geom.GeometryManager;
37
import org.gvsig.fmap.geom.primitive.Curve;
38

    
39
//import com.vividsolutions.jts.algorithm.RobustCGAlgorithms;
40
//import com.vividsolutions.jts.geom.Coordinate;
41

    
42
/**
43
 * @author FJP
44
 *
45
 *         TODO To change the template for this generated type comment go to
46
 *         Window - Preferences - Java - Code Generation - Code and Comments
47
 * @deprecated to be removed or moved from API to implementation in gvSIG 2.1.0
48
 */
49
public class UtilFunctions {
50
        private static final Logger logger = LoggerFactory.getLogger(GeometryManager.class);
51

    
52
        static public Arc2D createCircle(Point2D p1, Point2D p2, Point2D p3) //, Graphics g)
53
    {
54
        double xC, yC, w, h;
55

    
56
        // Calculamos 2 secantes, tiramos perpendiculares por sus puntos
57
        // medios y obtenemos el centro. Luego calculamos el radio.
58
        // Puntos medios de los segmentos.
59
        double xm1, ym1, xm2, ym2;
60
        xm1 = (p1.getX() + p2.getX())/ 2.0;
61
        ym1 = (p1.getY() + p2.getY())/ 2.0;
62
        xm2 = (p2.getX() + p3.getX())/ 2.0;
63
        ym2 = (p2.getY() + p3.getY())/ 2.0;
64

    
65
        /* g.setColor(Color.GRAY);
66
        g.draw3DRect((int)xm1, (int) ym1, 1, 1, true);
67
        g.draw3DRect((int)xm2, (int) ym2, 1, 1, true); */
68
        // Pendientes de las perpendiculares y constantes
69
        double mP1=0, mP2=0, A1, A2;
70
        boolean bPerp1 = false;
71
        //boolean bPerp2 = false;
72
        if (p2.getY() - p1.getY() == 0)
73
        {
74
            A1 = ym1;
75
            bPerp1 = true;
76
        }
77
        else
78
        {
79
            mP1 = (p2.getX() - p1.getX()) /(p1.getY() - p2.getY());
80
            A1 = ym1 - xm1 * mP1;
81
        }
82
        if (p2.getY() - p3.getY() == 0)
83
        {
84
            A2 = ym2;
85
            //bPerp2 = true;
86
        }
87
        else
88
        {
89
            mP2 = (p3.getX() - p2.getX()) /(p2.getY() - p3.getY());
90
            A2 = ym2 - xm2 * mP2;
91
        }
92
        if (mP2 == mP1)
93
        {
94
            return null; // Error, 3 puntos alineados. No puede pasar un arco
95
        }
96
        else
97
        {
98
            xC = (A2 - A1)/(mP1-mP2);
99
            if (!bPerp1) {
100
                                yC = xC * mP1 + A1;
101
                        } else {
102
                                yC = xC * mP2 + A2;
103
                        }
104
        }
105
        double Radio = p1.distance(xC, yC);
106
        double xR = xC - Radio ;
107
        double yR = yC - Radio ;
108
        w = 2.0* Radio;
109
        h = w;
110
        Rectangle2D.Double rBounds = new Rectangle2D.Double(xR,yR, w,h);
111
        Arc2D.Double resul = new Arc2D.Double(rBounds, 0.0, 360.0, Arc2D.OPEN);
112
                /* g.setColor(Color.RED);
113
                ((Graphics2D) g).draw(resul);
114
                g.setColor(Color.BLUE);
115
                ((Graphics2D) g).draw(rBounds);
116
                g.draw3DRect((int)p1.getX(), (int) p1.getY(), 1, 1, true);
117
                g.draw3DRect((int)p2.getX(), (int) p2.getY(), 2, 2, true);
118
                g.draw3DRect((int)p3.getX(), (int) p3.getY(), 1, 1, true);
119
                g.drawString("1", (int) p1.getX(), (int) p1.getY());
120
                g.drawString("2", (int) p2.getX(), (int) p2.getY());
121
                g.drawString("3", (int) p3.getX(), (int) p3.getY());
122
                g.drawString("C", (int) xC, (int) yC);
123
                g.draw3DRect((int)xC, (int) yC, 2, 2, true); */
124

    
125
        return resul;
126
    }
127
    /**
128
         * Obtiene un par de puntos que definen la recta perpendicular a p1-p2 que
129
         * pasa por el punto perp
130
         *
131
         * @param p1 punto de la recta p1-p2
132
         * @param p2 punto de la recta p1-p2
133
         * @param perp Punto por el que pasa la recta perpendicular, debe ser
134
         *                   distinto a p2
135
         *
136
         * @return Array con dos puntos que definen la recta resultante
137
         * @deprecated
138
         *         use the perpendicular operation
139
         */
140
        public static Point2D[] getPerpendicular(Point2D p1, Point2D p2,
141
                Point2D perp) {
142
                if ((p2.getY() - p1.getY()) == 0) {
143
                        return new Point2D[] {
144
                                new Point2D.Double(perp.getX(), 0),
145
                                new Point2D.Double(perp.getX(), 1)
146
                        };
147
                }
148

    
149
                //Pendiente de la recta perpendicular
150
                double m = (p1.getX() - p2.getX()) / (p2.getY() - p1.getY());
151

    
152
                //b de la funcion de la recta perpendicular
153
                double b = perp.getY() - (m * perp.getX());
154

    
155
                //Obtenemos un par de puntos
156
                Point2D[] res = new Point2D[2];
157

    
158
                res[0] = new Point2D.Double(0, (m * 0) + b);
159
                res[1] = new Point2D.Double(1000, (m * 1000) + b);
160

    
161
                return res;
162
        }
163
        public static Point2D[] getParallel(Point2D p1,Point2D p2,double distance) {
164
                Point2D[] pParallel=new Point2D[2];
165
                pParallel[0]=getPerpendicularPoint(p1,p2,p1,distance);
166
                pParallel[1]=getPerpendicularPoint(p1,p2,p2,distance);
167
                return pParallel;
168
        }
169

    
170
        /**
171
         * Obtiene el punto que se encuentra a una distancia 'dist' de la recta
172
         * p1-p2 y se encuentra en la recta perpendicular que pasa por perpPoint
173
         *
174
         * @param p1 Punto de la recta p1-p2
175
         * @param p2 Punto de la recta p1-p2
176
         * @param perpPoint Punto de la recta perpendicular
177
         * @param dist Distancia del punto que se quiere obtener a la recta p1-p2
178
         *
179
         * @return DOCUMENT ME!
180
         * @deprecated
181
         *         Use the perpendicularPoint operation
182
         */
183
        public static Point2D getPerpendicularPoint(Point2D p1, Point2D p2,
184
                Point2D perpPoint, double dist) {
185
                Point2D[] p = getPerpendicular(p1, p2, perpPoint);
186
                Point2D unit = getUnitVector(p[0], p[1]);
187

    
188
                return new Point2D.Double(perpPoint.getX() + (unit.getX() * dist),
189
                        perpPoint.getY() + (unit.getY() * dist));
190
        }
191

    
192
        /**
193
         * Devuelve un vector unitario en forma de punto a partir de dos puntos.
194
         *
195
         * @param p1 punto origen.
196
         * @param p2 punto destino.
197
         *
198
         * @return vector unitario.
199
         * @deprecated
200
         *         use the UnitVector operation
201
         */
202
        public static Point2D getUnitVector(Point2D p1, Point2D p2) {
203
                Point2D paux = new Point2D.Double(p2.getX() - p1.getX(),
204
                                p2.getY() - p1.getY());
205
                double v = Math.sqrt(Math.pow(paux.getX(), 2d) +
206
                                Math.pow(paux.getY(), 2d));
207
                paux = new Point2D.Double(paux.getX() / v, paux.getY() / v);
208

    
209
                return paux;
210
        }
211
        /**
212
         * Obtiene el centro del c�rculo que pasa por los tres puntos que se pasan
213
         * como  par�metro
214
         *
215
         * @param p1 primer punto del c�rculo cuyo centro se quiere obtener
216
         * @param p2 segundo punto del c�rculo cuyo centro se quiere obtener
217
         * @param p3 tercer punto del c�rculo cuyo centro se quiere obtener
218
         *
219
         * @return Devuelve null si los puntos est�n alineados o no son 3 puntos
220
         *                    distintos
221
         */
222
        public static Point2D getCenter(Point2D p1, Point2D p2, Point2D p3) {
223
                if (p1.equals(p2) || p2.equals(p3) || p1.equals(p3)) {
224
                        return null;
225
                }
226

    
227
                Point2D[] perp1 = getPerpendicular(p1, p2,
228
                                new Point2D.Double((p1.getX() + p2.getX()) / 2,
229
                                        (p1.getY() + p2.getY()) / 2));
230
                Point2D[] perp2 = getPerpendicular(p2, p3,
231
                                new Point2D.Double((p2.getX() + p3.getX()) / 2,
232
                                        (p2.getY() + p3.getY()) / 2));
233

    
234
                return getIntersection(perp1[0], perp1[1], perp2[0], perp2[1]);
235
        }
236

    
237

    
238
        /**
239
         * Devuelve el punto de la intersecci�n entre las lineas p1-p2 y p3-p4.
240
         *
241
         * @param p1 punto de la recta p1-p2
242
         * @param p2 punto de la recta p1-p2
243
         * @param p3 punto de la recta p3-p4
244
         * @param p4 punto de la recta p3-p4
245
         *
246
         * @return DOCUMENT ME!
247
         *
248
         * @throws RuntimeException DOCUMENT ME!
249
         */
250
        public static Point2D getIntersection(Point2D p1, Point2D p2, Point2D p3,
251
                Point2D p4) {
252
                double m1 = Double.POSITIVE_INFINITY;
253

    
254
                if ((p2.getX() - p1.getX()) != 0) {
255
                        m1 = (p2.getY() - p1.getY()) / (p2.getX() - p1.getX());
256
                }
257

    
258
                double m2 = Double.POSITIVE_INFINITY;
259

    
260
                if ((p4.getX() - p3.getX()) != 0) {
261
                        m2 = (p4.getY() - p3.getY()) / (p4.getX() - p3.getX());
262
                }
263

    
264
                if ((m1 == Double.POSITIVE_INFINITY) &&
265
                                (m2 == Double.POSITIVE_INFINITY)) {
266
                        return null;
267
                }
268

    
269
                double b1 = p2.getY() - (m1 * p2.getX());
270

    
271
                double b2 = p4.getY() - (m2 * p4.getX());
272

    
273
                if ((m1 != Double.POSITIVE_INFINITY) &&
274
                                (m2 != Double.POSITIVE_INFINITY)) {
275
                        if (m1 == m2) {
276
                                return null;
277
                        }
278

    
279
                        double x = (b2 - b1) / (m1 - m2);
280

    
281
                        return new Point2D.Double(x, (m1 * x) + b1);
282
                } else if (m1 == Double.POSITIVE_INFINITY) {
283
                        double x = p1.getX();
284

    
285
                        return new Point2D.Double(x, (m2 * x) + b2);
286
                } else if (m2 == Double.POSITIVE_INFINITY) {
287
                        double x = p3.getX();
288

    
289
                        return new Point2D.Double(x, (m1 * x) + b1);
290
                }
291

    
292
                //no llega nunca
293
                throw new RuntimeException("BUG!");
294
        }
295
        /**
296
         * Obtiene el �ngulo del vector que se pasa como par�metro con el vector
297
         * horizontal de izquierda a derecha
298
         *
299
         * @param start punto origen del vector
300
         * @param end punto destino del vector
301
         *
302
         * @return angulo en radianes
303
         */
304
        public static double getAngle(Point2D start, Point2D end) {
305
                double angle = Math.acos((end.getX() - start.getX()) / start.distance(
306
                                        end));
307

    
308
                if (start.getY() > end.getY()) {
309
                        angle = -angle;
310
                }
311

    
312
                if (angle < 0) {
313
                        angle += (2 * Math.PI);
314
                }
315

    
316
                return angle;
317
        }
318
        /**
319
         * Devuelve la distancia desde angle1 a angle2. Angulo en radianes de
320
         * diferencia entre angle1 y angle2 en sentido antihorario
321
         *
322
         * @param angle1 angulo en radianes. Debe ser positivo y no dar ninguna
323
         *                   vuelta a la circunferencia
324
         * @param angle2 angulo en radianes. Debe ser positivo y no dar ninguna
325
         *                   vuelta a la circunferencia
326
         *
327
         * @return distancia entre los �ngulos
328
         */
329
        public static double angleDistance(double angle1, double angle2) {
330
                if (angle1 < angle2) {
331
                        return angle2 - angle1;
332
                } else {
333
                        return ((Math.PI * 2) - angle1) + angle2;
334
                }
335
        }
336
        /**
337
         * Devuelve el punto de la recta que viene dada por los puntos p1 y p2 a
338
         * una distancia radio de p1.
339
         *
340
         * @param p1 DOCUMENT ME!
341
         * @param p2 DOCUMENT ME!
342
         * @param radio DOCUMENT ME!
343
         *
344
         * @return DOCUMENT ME!
345
         */
346
        public static Point2D getPoint(Point2D p1, Point2D p2, double radio) {
347
                Point2D paux = new Point2D.Double(p2.getX() - p1.getX(),
348
                                p2.getY() - p1.getY());
349
                double v = Math.sqrt(Math.pow(paux.getX(), 2d) +
350
                                Math.pow(paux.getY(), 2d));
351
                paux = new Point2D.Double(paux.getX() / v, paux.getY() / v);
352

    
353
                Point2D aux1 = new Point2D.Double(p1.getX() + (radio * paux.getX()),
354
                                p1.getY() + (radio * paux.getY()));
355

    
356
                return aux1;
357
        }
358
        /**
359
         * Devuelve la menor distancia desde angle1 a angle2.
360
         *
361
         * @param angle1 angulo en radianes. Debe ser positivo y no dar ninguna
362
         *                   vuelta a la circunferencia
363
         * @param angle2 angulo en radianes. Debe ser positivo y no dar ninguna
364
         *                   vuelta a la circunferencia
365
         *
366
         * @return distancia entre los �ngulos
367
         */
368
        public static double absoluteAngleDistance(double angle1, double angle2) {
369
                double d = Math.abs(angle1 - angle2);
370

    
371
                if (d < Math.PI) {
372
                        return d;
373
                } else {
374
                        if (angle1 < angle2) {
375
                                angle2 -= (Math.PI * 2);
376
                        } else {
377
                                angle1 -= (Math.PI * 2);
378
                        }
379

    
380
                        return Math.abs(angle1 - angle2);
381
                }
382
        }
383
        /**
384
         * Obtiene un arco a partir de 3 puntos. Devuelve null si no se puede crear
385
         * el arco porque los puntos est�n alineados o los 3 puntos no son
386
         * distintos
387
         *
388
         * @param p1
389
         * @param p2
390
         * @param p3
391
         *
392
         * @return Arco
393
         */
394
        public static Arc2D createArc(Point2D p1, Point2D p2, Point2D p3) {
395
                Point2D center = getCenter(p1, p2, p3);
396

    
397
                double angle1;
398
                double angle2;
399
                double extent;
400

    
401
                if (center == null) {
402
                        if (p1.equals(p3) && !p2.equals(p1)) {
403
                                //Si los puntos p1 y p3 son los mismos (pero el p2 no),
404
                                //consideramos que el arco es una circunferencia completa
405
                                center = new Point2D.Double((p1.getX() + p2.getX()) / 2,
406
                                                        (p1.getY() + p2.getY()) / 2);
407
                                angle1 = getAngle(center, p1);
408
                                extent = Math.PI*2;
409
                        } else {
410
                                //en cualquier otro caso, no podemos crear el arco.
411
                                return null;
412
                        }
413
                } else {
414
                    angle1 = getAngle(center, p1);
415
                    angle2 = getAngle(center, p3);
416
                    extent = angleDistance(angle1, angle2);
417

    
418
                    try {
419
                        GeometryManager manager = GeometryLocator.getGeometryManager();
420
                        Curve line = manager.createCurve(Geometry.SUBTYPES.GEOM2D);
421
                        line.addVertex(p1.getX(), p1.getY());
422
                        line.addVertex(p2.getX(), p2.getY());
423
                        line.addVertex(p3.getX(), p3.getY());
424
                        line.addVertex(p1.getX(), p1.getY());
425
                        if( line.isCCW() ) {
426
                            extent = (Math.PI * 2) - extent;
427
                        } else {
428
                            extent = -extent;
429
                        }
430
                    } catch (Exception ex) {
431
                        logger.warn("Can't determine CCW of the Arc",ex);
432
                        extent = -extent;
433
                    }
434
                }
435
                //System.err.println("angle1:" + angle1);
436
                //System.err.println("angle2:" + getAngle(center, p2));
437
                //System.err.println("angle3:" + angle2);
438
                //System.err.println("extent:" + extent);
439
                double Radio = p1.distance(center);
440
                double xR = center.getX() - Radio;
441
                double yR = center.getY() - Radio;
442
                double w = 2.0 * Radio;
443
                double h = w;
444

    
445
                Rectangle2D.Double rBounds = new Rectangle2D.Double(xR, yR, w, h);
446
                Arc2D.Double resul = new Arc2D.Double(rBounds,
447
                                Math.toDegrees((Math.PI * 2) - angle1), Math.toDegrees(extent),
448
                                Arc2D.OPEN);
449

    
450
                return resul;
451
        }
452

    
453
        /**
454
         * Obtiene un arco a partir del centro, radio, angulo inicial y extension del angulo.
455
         * Devuelve null si no lo puede crear.
456
         *
457
         * @param center
458
         * @param radius
459
         * @param angSt en radianes
460
         * @param angExt en radianes
461
         *
462
         * @return Arco
463
         */
464
        public static Arc2D createArc(Point2D center, double radius, double angSt, double angExt) {
465
                double xR = center.getX() - radius;
466
                double yR = center.getY() - radius;
467
                double w = 2.0 * radius;
468
                double h = w;
469

    
470
                Rectangle2D.Double rBounds = new Rectangle2D.Double(xR, yR, w, h);
471
                Arc2D.Double resul = new Arc2D.Double(rBounds,
472
                                Math.toDegrees((Math.PI * 2) - angSt), Math.toDegrees(angExt),
473
                                Arc2D.OPEN);
474

    
475
                return resul;
476
        }
477

    
478
        /**
479
         * Obtiene un arco a partir del
480
         *  centro del arco y punto inicio y punto final
481
         *  Suponemos un Arco definicio CCW (CounterClockWise)
482
         * @param center
483
         * @param init
484
         * @param end
485
         *
486
         * @return Arco
487
         */
488
        public static Arc2D createArc2points(Point2D center, Point2D init, Point2D end) {
489

    
490
                double angle1 = getAngle(center, init);
491
                double angle2 = getAngle(center, end);
492
                double extent = angleDistance(angle1, angle2);
493

    
494
                extent = -extent; // CCW
495

    
496
                //System.err.println("angle1:" + angle1);
497
                //System.err.println("angle2:" + getAngle(center, p2));
498
                //System.err.println("angle3:" + angle2);
499
                //System.err.println("extent:" + extent);
500
                double Radio = init.distance(center);
501
                double xR = center.getX() - Radio;
502
                double yR = center.getY() - Radio;
503
                double w = 2.0 * Radio;
504
                double h = w;
505

    
506
                Rectangle2D.Double rBounds = new Rectangle2D.Double(xR, yR, w, h);
507
                Arc2D.Double resul = new Arc2D.Double(rBounds,
508
                                Math.toDegrees((Math.PI * 2) - angle1), Math.toDegrees(extent),
509
                                Arc2D.OPEN);
510

    
511
                return resul;
512
        }
513

    
514
        /**
515
         * Devuelve el punto a una distancia radio del punto p1 y aplicandole un �ngulo an.
516
         * una distancia radio de p1.
517
         *
518
         * @param p1 DOCUMENT ME!
519
         * @param p2 DOCUMENT ME!
520
         * @param radio DOCUMENT ME!
521
         *
522
         * @return DOCUMENT ME!
523
         */
524
        public static Point2D getPoint(Point2D p1, double an, double radio) {
525
                double x=(radio*Math.cos(an))+p1.getX();
526
                double y=(radio*Math.sin(an))+p1.getY();
527

    
528
                Point2D p=new Point2D.Double(x,y);
529

    
530
                return p;
531
        }
532

    
533
        /**
534
         * Obtiene una linea a partir de dos puntos.
535
         * Devuelve null si no lo puede crear.
536
         *
537
         * @param start
538
         * @param end
539
         *
540
         * @return Linea
541
         */
542
        public static Line2D createLine(Point2D start, Point2D end) {
543
                return new Line2D.Double(start, end);
544

    
545
        }
546

    
547

    
548
        /**
549
         * DOCUMENT ME!
550
         *
551
         * @param antp DOCUMENT ME!
552
         * @param lastp DOCUMENT ME!
553
         * @param interp DOCUMENT ME!
554
         * @param point DOCUMENT ME!
555
         *
556
         * @return DOCUMENT ME!
557
         */
558
        public static boolean isLowAngle(Point2D antp, Point2D lastp,
559
                Point2D interp, Point2D point) {
560
                ///double ob=lastp.distance(point);
561
                ///Point2D[] aux=getPerpendicular(lastp,interp,point);
562
                ///Point2D intersect=getIntersection(aux[0],aux[1],lastp,interp);
563
                ///double pb=intersect.distance(point);
564
                ///double a=Math.asin(pb/ob);
565

    
566
                boolean isCCW = true;
567
                try {
568
                    GeometryManager manager = GeometryLocator.getGeometryManager();
569
                    Curve line;
570
                    line = manager.createCurve(Geometry.SUBTYPES.GEOM2D);
571
                    line.addVertex(lastp.getX(), lastp.getY());
572
                    line.addVertex(interp.getX(), interp.getY());
573
                    line.addVertex(point.getX(), point.getY());
574
                    line.addVertex(lastp.getX(), lastp.getY());
575
                    isCCW = line.isCCW();
576
                } catch (Exception ex) {
577
                    logger.warn("Can't determine CCW of angle.",ex);
578
                }
579

    
580
                try {
581
                        double angle1 = getAngle(antp, lastp);
582
                        // System.out.println("angle1= " + angle1);
583

    
584
                        double angle2 = getAngle(lastp, point);
585
                        // System.out.println("angle2= " + angle2);
586

    
587
                        /*if (lastp.getX()<antp.getX()){
588
                           System.out.println("angleDiff 2 1= "+angleDistance(angle2,angle1));
589
                           System.out.println("angleDiff 1 2= "+angleDistance(angle1,angle2));
590
                           if (angleDistance(angle2,angle1)>Math.PI){
591

592
                           if (RobustCGAlgorithms.isCCW(coords)) {
593
                                   System.out.println("izquierda,arriba,true");
594
                                   return true;
595
                           } else{
596
                                   System.out.println("izquierda,arriba,false");
597
                           }
598
                           }else {
599
                                   if (!RobustCGAlgorithms.isCCW(coords)) {
600
                                           System.out.println("izquierda,abajo,true");
601
                                           return true;
602
                                   } else{
603
                                           System.out.println("izquierda,abajo,false");
604
                                   }
605
                           }
606
                           }else if (lastp.getX()>antp.getX()){
607
                         */
608

    
609
                        /*
610
                        System.out.println("angleDifl 2 1= " +
611
                                angleDistance(angle2, angle1));
612
                        System.out.println("angleDifl 1 2= " +
613
                                angleDistance(angle1, angle2));
614
                        */
615

    
616
                        if (angleDistance(angle2, angle1) > Math.PI) {
617
                                if (isCCW) {
618
                                        // System.out.println("derecha,arriba,true");
619

    
620
                                        return true;
621
                                } else {
622
                                        // System.out.println("derecha,arriba,false");
623
                                }
624
                        } else {
625
                                if (!isCCW) {
626
                                        // System.out.println("derecha,abajo,true");
627

    
628
                                        return true;
629
                                } else {
630
                                    // System.out.println("derecha,abajo,false");
631
                                }
632
                        }
633

    
634
                        //}
635
                } catch (Exception e) {
636
                        // System.out.println("false");
637

    
638
                        return true;
639
                }
640

    
641
                return false;
642
        }
643

    
644

    
645

    
646

    
647
}