Package toxi.geom.Line2D

Examples of toxi.geom.Line2D.LineIntersection


            return;
        }

        Line2D l1 = new Line2D(new Vec2D(x1, y1), new Vec2D(c1, d1));
        Line2D l2 = new Line2D(new Vec2D(c2, d2), new Vec2D(x3, y3));
        LineIntersection isec = l1.intersectLine(l2);
        final Vec2D ipos = isec.getPos();
        if (ipos != null) {
            out.set(ipos);
        }
    }
View Full Code Here


        // 2. Break the segments up at their intersection points.
        for (i = 0; i < segs - 1; i++) {
            for (j = i + 1; j < segs; j++) {
                Line2D li = new Line2D(segments[i], segEnds[i]);
                Line2D lj = new Line2D(segments[j], segEnds[j]);
                LineIntersection isec = li.intersectLine(lj);
                if (isec.getType() == Type.INTERSECTING) {
                    Vec2D ipos = isec.getPos();
                    if (!ipos.equals(segments[i]) && !ipos.equals(segEnds[i])) {
                        if (segs == maxSegs) {
                            return false;
                        }
                        segments[segs] = segments[i].copy();
View Full Code Here

    public LineIntersection intersectLine(Line2D line) {
        Line2D l = new Line2D(new Vec2D(), new Vec2D());
        for (int i = 1, num = vertices.size(); i < num; i++) {
            l.set(vertices.get(i - 1), vertices.get(i));
            LineIntersection isec = l.intersectLine(line);
            if (isec.getType() == Type.INTERSECTING
                    || isec.getType() == Type.COINCIDENT) {
                return isec;
            }
        }
        return null;
    }
View Full Code Here

    }

    public void testIntersection() {
        Line2D l = new Line2D(new Vec2D(), new Vec2D(100, 100));
        Line2D k = new Line2D(new Vec2D(0, 50), new Vec2D(100, 50));
        LineIntersection isec = l.intersectLine(k);
        assertEquals(LineIntersection.Type.INTERSECTING, isec.getType());
        assertEquals(new Vec2D(50, 50), isec.getPos());
        k = l.copy();
        assertEquals(LineIntersection.Type.COINCIDENT, l.intersectLine(k)
                .getType());
        k = new Line2D(new Vec2D(110, 110), new Vec2D(220, 220));
        assertEquals(LineIntersection.Type.COINCIDENT_NO_INTERSECT, l
View Full Code Here

TOP

Related Classes of toxi.geom.Line2D.LineIntersection

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.