Statistics
| Revision:

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

History | View | Annotate | Download (18 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.util;
25

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

    
32
import org.gvsig.fmap.geom.Geometry;
33
import org.gvsig.fmap.geom.GeometryManager;
34
import org.slf4j.Logger;
35
import org.slf4j.LoggerFactory;
36

    
37
import com.vividsolutions.jts.algorithm.RobustCGAlgorithms;
38
import com.vividsolutions.jts.geom.Coordinate;
39

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

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

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

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

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

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

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

    
153
                //Obtenemos un par de puntos
154
                Point2D[] res = new Point2D[2];
155

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

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

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

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

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

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

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

    
232
                return getIntersection(perp1[0], perp1[1], perp2[0], perp2[1]);
233
        }
234

    
235

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

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

    
256
                double m2 = Double.POSITIVE_INFINITY;
257

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

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

    
267
                double b1 = p2.getY() - (m1 * p2.getX());
268

    
269
                double b2 = p4.getY() - (m2 * p4.getX());
270

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

    
277
                        double x = (b2 - b1) / (m1 - m2);
278

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

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

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

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

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

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

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

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

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

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

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

    
395
                double angle1;
396
                double angle2;
397
                double extent;
398

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

    
413
                        angle1 = getAngle(center, p1);
414
                        angle2 = getAngle(center, p3);
415
                        extent = angleDistance(angle1, angle2);
416

    
417
                        Coordinate[] coords = new Coordinate[4];
418
                        coords[0] = new Coordinate(p1.getX(), p1.getY());
419
                        coords[1] = new Coordinate(p2.getX(), p2.getY());
420
                        coords[2] = new Coordinate(p3.getX(), p3.getY());
421
                        coords[3] = new Coordinate(p1.getX(), p1.getY());
422

    
423
                        if (!RobustCGAlgorithms.isCCW(coords)) {
424
                                extent = (Math.PI * 2) - extent;
425
                        } else {
426
                                extent = -extent;
427
                        }
428
                }
429
                //System.err.println("angle1:" + angle1);
430
                //System.err.println("angle2:" + getAngle(center, p2));
431
                //System.err.println("angle3:" + angle2);
432
                //System.err.println("extent:" + extent);
433
                double Radio = p1.distance(center);
434
                double xR = center.getX() - Radio;
435
                double yR = center.getY() - Radio;
436
                double w = 2.0 * Radio;
437
                double h = w;
438

    
439
                Rectangle2D.Double rBounds = new Rectangle2D.Double(xR, yR, w, h);
440
                Arc2D.Double resul = new Arc2D.Double(rBounds,
441
                                Math.toDegrees((Math.PI * 2) - angle1), Math.toDegrees(extent),
442
                                Arc2D.OPEN);
443

    
444
                return resul;
445
        }
446

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

    
464
                Rectangle2D.Double rBounds = new Rectangle2D.Double(xR, yR, w, h);
465
                Arc2D.Double resul = new Arc2D.Double(rBounds,
466
                                Math.toDegrees((Math.PI * 2) - angSt), Math.toDegrees(angExt),
467
                                Arc2D.OPEN);
468

    
469
                return resul;
470
        }
471

    
472
        /**
473
         * Obtiene un arco a partir del
474
         *  centro del arco y punto inicio y punto final
475
         *  Suponemos un Arco definicio CCW (CounterClockWise)
476
         * @param center
477
         * @param init
478
         * @param end
479
         *
480
         * @return Arco
481
         */
482
        public static Arc2D createArc2points(Point2D center, Point2D init, Point2D end) {
483

    
484
                double angle1 = getAngle(center, init);
485
                double angle2 = getAngle(center, end);
486
                double extent = angleDistance(angle1, angle2);
487

    
488
                extent = -extent; // CCW
489

    
490
                //System.err.println("angle1:" + angle1);
491
                //System.err.println("angle2:" + getAngle(center, p2));
492
                //System.err.println("angle3:" + angle2);
493
                //System.err.println("extent:" + extent);
494
                double Radio = init.distance(center);
495
                double xR = center.getX() - Radio;
496
                double yR = center.getY() - Radio;
497
                double w = 2.0 * Radio;
498
                double h = w;
499

    
500
                Rectangle2D.Double rBounds = new Rectangle2D.Double(xR, yR, w, h);
501
                Arc2D.Double resul = new Arc2D.Double(rBounds,
502
                                Math.toDegrees((Math.PI * 2) - angle1), Math.toDegrees(extent),
503
                                Arc2D.OPEN);
504

    
505
                return resul;
506
        }
507

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

    
522
                Point2D p=new Point2D.Double(x,y);
523

    
524
                return p;
525
        }
526

    
527
        /**
528
         * Obtiene una linea a partir de dos puntos.
529
         * Devuelve null si no lo puede crear.
530
         *
531
         * @param start
532
         * @param end
533
         *
534
         * @return Linea
535
         */
536
        public static Line2D createLine(Point2D start, Point2D end) {
537
                return new Line2D.Double(start, end);
538

    
539
        }
540

    
541

    
542
        /**
543
         * DOCUMENT ME!
544
         *
545
         * @param antp DOCUMENT ME!
546
         * @param lastp DOCUMENT ME!
547
         * @param interp DOCUMENT ME!
548
         * @param point DOCUMENT ME!
549
         *
550
         * @return DOCUMENT ME!
551
         */
552
        public static boolean isLowAngle(Point2D antp, Point2D lastp,
553
                Point2D interp, Point2D point) {
554
                ///double ob=lastp.distance(point);
555
                ///Point2D[] aux=getPerpendicular(lastp,interp,point);
556
                ///Point2D intersect=getIntersection(aux[0],aux[1],lastp,interp);
557
                ///double pb=intersect.distance(point);
558
                ///double a=Math.asin(pb/ob);
559
                Coordinate[] coords = new Coordinate[4];
560
                coords[0] = new Coordinate(lastp.getX(), lastp.getY());
561
                coords[1] = new Coordinate(interp.getX(), interp.getY());
562
                coords[2] = new Coordinate(point.getX(), point.getY());
563
                coords[3] = new Coordinate(lastp.getX(), lastp.getY());
564

    
565
                try {
566
                        double angle1 = getAngle(antp, lastp);
567
                        // System.out.println("angle1= " + angle1);
568

    
569
                        double angle2 = getAngle(lastp, point);
570
                        // System.out.println("angle2= " + angle2);
571

    
572
                        /*if (lastp.getX()<antp.getX()){
573
                           System.out.println("angleDiff 2 1= "+angleDistance(angle2,angle1));
574
                           System.out.println("angleDiff 1 2= "+angleDistance(angle1,angle2));
575
                           if (angleDistance(angle2,angle1)>Math.PI){
576

577
                           if (RobustCGAlgorithms.isCCW(coords)) {
578
                                   System.out.println("izquierda,arriba,true");
579
                                   return true;
580
                           } else{
581
                                   System.out.println("izquierda,arriba,false");
582
                           }
583
                           }else {
584
                                   if (!RobustCGAlgorithms.isCCW(coords)) {
585
                                           System.out.println("izquierda,abajo,true");
586
                                           return true;
587
                                   } else{
588
                                           System.out.println("izquierda,abajo,false");
589
                                   }
590
                           }
591
                           }else if (lastp.getX()>antp.getX()){
592
                         */
593
                        
594
                        /*
595
                        System.out.println("angleDifl 2 1= " +
596
                                angleDistance(angle2, angle1));
597
                        System.out.println("angleDifl 1 2= " +
598
                                angleDistance(angle1, angle2));
599
                        */
600

    
601
                        if (angleDistance(angle2, angle1) > Math.PI) {
602
                                if (RobustCGAlgorithms.isCCW(coords)) {
603
                                        // System.out.println("derecha,arriba,true");
604

    
605
                                        return true;
606
                                } else {
607
                                        // System.out.println("derecha,arriba,false");
608
                                }
609
                        } else {
610
                                if (!RobustCGAlgorithms.isCCW(coords)) {
611
                                        // System.out.println("derecha,abajo,true");
612

    
613
                                        return true;
614
                                } else {
615
                                    // System.out.println("derecha,abajo,false");
616
                                }
617
                        }
618

    
619
                        //}
620
                } catch (Exception e) {
621
                        // System.out.println("false");
622

    
623
                        return true;
624
                }
625

    
626
                return false;
627
        }
628

    
629

    
630

    
631

    
632
}