// Path: kendzi-math-geometry/src/main/java/kendzi/math/geometry/line/LinePoints2d.java
// public class LinePoints2d {
//     /**
//      * Start point A. XXX rename to A ?
//      */
//     Point2d p1;
//     /**
//      * End point B. XXX rename to B ?
//      */
//     Point2d p2;
// 
//     public LinePoints2d(Point2d p1, Point2d p2) {
//         this.p1 = p1;
//         this.p2 = p2;
//     }
// 
//     public Point2d getP1() {
//         return this.p1;
//     }
// 
//     public void setP1(Point2d p1) {
//         this.p1 = p1;
//     }
// 
//     public Point2d getP2() {
//         return this.p2;
//     }
// 
//     public void setP2(Point2d p2) {
//         this.p2 = p2;
//     }
// 
//     /**
//      * Starting Point A from parametric description.
//      *
//      * @return starting point A.
//      */
//     Point2d getPointA() {
//         return this.p1;
//     }
// 
//     /**
//      * Direction vector U from parametric description.
//      *
//      * @return direction vector U.
//      */
//     Vector2d getVectorU() {
//         Vector2d u = new Vector2d(this.p2);
//         u.sub(this.p1);
//         return u;
//     }
// 
//     public LineParametric2d getLineParametric2d() {
//         return new LineParametric2d(getPointA(), getVectorU());
//     }
// 
// 
//     /** Determinate if point is over line or on line.
//      * @param pPoint point
//      * @return point is over line or on line
//      * TODO RENAME TO POINT_IN_FRONT
//      */
//     public boolean inFront(Tuple2d pPoint) {
//         return LineUtil.matrixDet(this.p1, this.p2, pPoint) >= 0;
//     }
// 
//     /**
//      * {@inheritDoc}
//      *
//      * @see java.lang.Object#toString()
//      */
//     @Override
//     public String toString() {
//         return "L (" + this.p1 + ") -> (" + this.p2 + ")";
//     }
// 
// 
// 
// 
// }
// 
// Path: kendzi-math-geometry/src/main/java/kendzi/math/geometry/polygon/split/PlygonSplitUtil.java
// public static class SplitResult {
//     private final List<List<Point2d>> leftPolygons;
//     private final List<List<Point2d>> rightPolygons;
// 
//     public SplitResult(List<List<Point2d>> leftPolygons, List<List<Point2d>> rightPolygons) {
//         super();
//         this.leftPolygons = leftPolygons;
//         this.rightPolygons = rightPolygons;
//     }
// 
//     /**
//      * @return the leftPolygons
//      */
//     public List<List<Point2d>> getLeftPolygons() {
//         return leftPolygons;
//     }
// 
//     /**
//      * @return the rightPolygons
//      */
//     public List<List<Point2d>> getRightPolygons() {
//         return rightPolygons;
//     }
// 
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.vecmath.Point2d;
import kendzi.math.geometry.line.LinePoints2d;
import kendzi.math.geometry.polygon.split.PlygonSplitUtil.SplitResult;
import org.junit.Test;


        split = PlygonSplitUtil.split(polygon, line);

        assertEquals(0, split.getLeftPolygons().size());
        assertEquals(1, split.getRightPolygons().size());
        assertEqualsPolygon(polygon(p0, p1, p2, p3), split.getRightPolygons().get(0));

    }

    @SuppressWarnings("javadoc")
    @Test
    public void polygon1() {
        // polygon points
        Point2d p0 = debugPoint(0, -1, -1);
        Point2d p1 = debugPoint(1, 0, 1);
        Point2d p2 = debugPoint(2, 1, -1);
        Point2d p3 = debugPoint(3, 0, 2);

        // generated splitting points
        Point2d s0 = debugPoint("s0", -2d / 3d, 0);
        Point2d s1 = debugPoint("s1", -0.5, 0);
        Point2d s2 = debugPoint("s2", 0.5, 0);
        Point2d s3 = debugPoint("s3", 2d / 3d, 0);

        List<Point2d> polygon = new ArrayList<Point2d>();
        polygon.add(p0);
        polygon.add(p1);
        polygon.add(p2);
        polygon.add(p3);


// Path: kendzi-math-geometry/src/main/java/kendzi/math/geometry/line/LinePoints2d.java
// public class LinePoints2d {
//     /**
//      * Start point A. XXX rename to A ?
//      */
//     Point2d p1;
//     /**
//      * End point B. XXX rename to B ?
//      */
//     Point2d p2;
// 
//     public LinePoints2d(Point2d p1, Point2d p2) {
//         this.p1 = p1;
//         this.p2 = p2;
//     }
// 
//     public Point2d getP1() {
//         return this.p1;
//     }
// 
//     public void setP1(Point2d p1) {
//         this.p1 = p1;
//     }
// 
//     public Point2d getP2() {
//         return this.p2;
//     }
// 
//     public void setP2(Point2d p2) {
//         this.p2 = p2;
//     }
// 
//     /**
//      * Starting Point A from parametric description.
//      *
//      * @return starting point A.
//      */
//     Point2d getPointA() {
//         return this.p1;
//     }
// 
//     /**
//      * Direction vector U from parametric description.
//      *
//      * @return direction vector U.
//      */
//     Vector2d getVectorU() {
//         Vector2d u = new Vector2d(this.p2);
//         u.sub(this.p1);
//         return u;
//     }
// 
//     public LineParametric2d getLineParametric2d() {
//         return new LineParametric2d(getPointA(), getVectorU());
//     }
// 
// 
//     /** Determinate if point is over line or on line.
//      * @param pPoint point
//      * @return point is over line or on line
//      * TODO RENAME TO POINT_IN_FRONT
//      */
//     public boolean inFront(Tuple2d pPoint) {
//         return LineUtil.matrixDet(this.p1, this.p2, pPoint) >= 0;
//     }
// 
//     /**
//      * {@inheritDoc}
//      *
//      * @see java.lang.Object#toString()
//      */
//     @Override
//     public String toString() {
//         return "L (" + this.p1 + ") -> (" + this.p2 + ")";
//     }
// 
// 
// 
// 
// }
// 
// Path: kendzi-math-geometry/src/main/java/kendzi/math/geometry/polygon/split/PlygonSplitUtil.java
// public static class SplitResult {
//     private final List<List<Point2d>> leftPolygons;
//     private final List<List<Point2d>> rightPolygons;
// 
//     public SplitResult(List<List<Point2d>> leftPolygons, List<List<Point2d>> rightPolygons) {
//         super();
//         this.leftPolygons = leftPolygons;
//         this.rightPolygons = rightPolygons;
//     }
// 
//     /**
//      * @return the leftPolygons
//      */
//     public List<List<Point2d>> getLeftPolygons() {
//         return leftPolygons;
//     }
// 
//     /**
//      * @return the rightPolygons
//      */
//     public List<List<Point2d>> getRightPolygons() {
//         return rightPolygons;
//     }
// 
// }


// Path: kendzi-math-geometry/src/test/java/kendzi/math/geometry/polygon/split/PlygonSplitUtilTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.vecmath.Point2d;
import kendzi.math.geometry.line.LinePoints2d;
import kendzi.math.geometry.polygon.split.PlygonSplitUtil.SplitResult;
import org.junit.Test;


        split = PlygonSplitUtil.split(polygon, line);

        assertEquals(0, split.getLeftPolygons().size());
        assertEquals(1, split.getRightPolygons().size());
        assertEqualsPolygon(polygon(p0, p1, p2, p3), split.getRightPolygons().get(0));

    }

    @SuppressWarnings("javadoc")
    @Test
    public void polygon1() {
        // polygon points
        Point2d p0 = debugPoint(0, -1, -1);
        Point2d p1 = debugPoint(1, 0, 1);
        Point2d p2 = debugPoint(2, 1, -1);
        Point2d p3 = debugPoint(3, 0, 2);

        // generated splitting points
        Point2d s0 = debugPoint("s0", -2d / 3d, 0);
        Point2d s1 = debugPoint("s1", -0.5, 0);
        Point2d s2 = debugPoint("s2", 0.5, 0);
        Point2d s3 = debugPoint("s3", 2d / 3d, 0);

        List<Point2d> polygon = new ArrayList<Point2d>();
        polygon.add(p0);
        polygon.add(p1);
        polygon.add(p2);
        polygon.add(p3);


        LinePoints2d line = new LinePoints2d(debugPoint("l1", 0, 0), debugPoint("l2", 1, 0));
