Package ru.dubov.primitives

Examples of ru.dubov.primitives.Point


        boolean isClockwise = p.isClockwise();
       
        while (p.size() > 3) {
           
            int li = -1;
            Point l, v, r;
            Triangle tr;
            boolean isEar;
            int tryings = 0;
           
            do {
View Full Code Here


        jPanel1.repaint();
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jPanel1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel1MousePressed
        if (state == 0) {
            Point pi = new Point(evt.getX(), jPanel1.getHeight() - evt.getY());
            polygon.add(pi);
           
            tempPolygon.remove(tempPolygon.size() - 1);
            tempPolygon.add(pi);
            tempPolygon.add(pi);
View Full Code Here

    }//GEN-LAST:event_jButton6ActionPerformed

    private void jPanel1MouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel1MouseMoved
       
        if (state == 0) {
            Point pi = new Point(evt.getX(), jPanel1.getHeight() - evt.getY());
            tempPolygon.remove(tempPolygon.size() - 1);
            tempPolygon.add(pi);
        }
       
        jPanel1.repaint();
View Full Code Here

    }//GEN-LAST:event_jPanel1MouseExited

    private void jPanel1MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel1MouseEntered
       
        if (state == 0) {
            Point pi = new Point(evt.getX(), jPanel1.getHeight() - evt.getY());
            tempPolygon.add(pi);
        }
       
        jPanel1.repaint();
    }//GEN-LAST:event_jPanel1MouseEntered
View Full Code Here

                pk.getY() <= Math.max(pi.getY(), pj.getY()));
    }
   
    public static boolean two(Segment s1, Segment s2) {
       
        Point p1 = s1.getLeft();
        Point p2 = s1.getRight();
        Point p3 = s2.getLeft();
        Point p4 = s2.getRight();
       
        double d1 = direction(p3, p4, p1);
        double d2 = direction(p3, p4, p2);
        double d3 = direction(p1, p2, p3);
        double d4 = direction(p1, p2, p4);
View Full Code Here

    private void jPanel1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel1MousePressed
             
        if (c == 4) c = 0;
       
        if (c == 0) {
            p1 = new Point(evt.getX(), evt.getY());
        } else if (c == 1) {
            p2 = new Point(evt.getX(), evt.getY());
        } else if (c == 2) {
            p3 = new Point(evt.getX(), evt.getY());
        } else if (c == 3) {
            p4 = new Point(evt.getX(), evt.getY());
            Segment s1 = new Segment(p1, p2);
            Segment s2 = new Segment(p3, p4);
            intersection = SegmentsIntersect.two(s1, s2);
        }
       
View Full Code Here

       
        // Test case 1
       
        segments = new ArrayList<Segment>();
       
        segments.add(new Segment(new Point(0, 0), new Point(1, 0)));
        segments.add(new Segment(new Point(2, 0), new Point(3, 0)));
        segments.add(new Segment(new Point(4, 0), new Point(5, 0)));
        segments.add(new Segment(new Point(4.3, 1), new Point(4.7, -1)));
        segments.add(new Segment(new Point(6, 0), new Point(7, 0)));
       
        assertTrue(SegmentsIntersect.any(segments));
       
        // Test case 2
       
        segments = new ArrayList<Segment>();
       
        segments.add(new Segment(new Point(0, 0), new Point(1, 0)));
        segments.add(new Segment(new Point(2, 0), new Point(3, 0)));
        segments.add(new Segment(new Point(4, 0), new Point(5, 0)));
       
        assertTrue(! SegmentsIntersect.any(segments));
    }
View Full Code Here

       
        // Test case 1
       
        segments = new ArrayList<Segment>();
       
        segments.add(new Segment(new Point(0, 0), new Point(2, 1)));
        segments.add(new Segment(new Point(2, 1), new Point(3, 0)));
        segments.add(new Segment(new Point(4, 0), new Point(5, 0)));
       
        assertTrue(SegmentsIntersect.any(segments));
       
        // Test case 2
       
        segments = new ArrayList<Segment>();
       
        segments.add(new Segment(new Point(0, 0), new Point(2, 1)));
        segments.add(new Segment(new Point(2, 2), new Point(3, 0)));
        segments.add(new Segment(new Point(2, 2), new Point(5, 0)));
       
        assertTrue(SegmentsIntersect.any(segments));
    }
View Full Code Here

        for (int repeat = 0; repeat < 1000; repeat++) {
            for (int i = 2; i <= 20; i++) {
                ArrayList<Segment> segments = new ArrayList<Segment>();

                for(int j = 0; j < i; j++) {
                    segments.add(new Segment(new Point(rand.nextDouble()*100, rand.nextDouble()*100),
                                             new Point(rand.nextDouble()*100, rand.nextDouble()*100)));
                }

                assertTrue(SegmentsIntersect.any(segments) ==
                            SegmentsIntersect.any_Naive(segments));
            }
View Full Code Here

     *
     * @return Triangulation
     */
    public static ArrayList<Triangle> some(List<Point> points) {
       
        Point p0 = getLowestPoint(points);
        points.remove(p0);
       
        Collections.sort(points, new PointComparator(p0));
       
        ArrayList<Triangle> result = new ArrayList<Triangle>();
       
        Stack<Point> S = new Stack<Point>();
        S.push(p0);
        S.push(points.get(0));
       
        Point top, nextToTop;
        Triangle lastAdded = null, temp = null,
                 lastAddedInStack = null, tempInStack = null;
       
        for (int i = 0; i < points.size(); i++) {
           
View Full Code Here

TOP

Related Classes of ru.dubov.primitives.Point

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.