CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

FileLine
math/geom2d/line/Polyline2DUtils.java188
math/geom2d/polygon/Polyline2DUtils.java193
    createClosedParallel(LinearRing2D polyline, double d) {

        // Collection of parallel curves
        BoundaryPolyCurve2D<SmoothOrientedCurve2D> result = 
            new BoundaryPolyCurve2D<SmoothOrientedCurve2D>();
        result.setClosed(true);

        // evacuate degenerate case.
        if (polyline.getVertices().size()<2)
            return result;

        // ----- declarations -----

        // vertices of the current edge
        Point2D v1, v2;

        // The corresponding parallel points, and the intersection point
        // for first curve
        Point2D p1, p2, p0 = null;

        // The line parallel to the previous and current line segments
        StraightLine2D line0, line;

        // Circle located at corners
        Circle2D circle;

        Iterator<Point2D> iterator;

        // ----- Initializations -----

        // Add eventually a circle arc, and the first line segment.

        // Extract parallel to last edge
        LineSegment2D lastEdge = polyline.getLastEdge();
        line0 = StraightLine2D.createParallel(lastEdge, d);

        v2 = lastEdge.getLastPoint();
        p0 = line0.getProjectedPoint(v2);

        // extract current vertices, and current parallel
        iterator = polyline.getVertices().iterator();
        v1 = iterator.next();
        v2 = iterator.next();
        line = new StraightLine2D(v1, v2).getParallel(d);

        // Check angle of the 2 lines
        p1 = line.getProjectedPoint(v1);
        if (Angle2D.getAngle(line0, line)>Math.PI^d<0) {
            // Line is going to the right -> next line segment will be
            // truncated
            p1 = line.getIntersection(line0);
            p0 = p1;
        } else {
            // line is going to the left -> add a circle arc
            circle = new Circle2D(v1, Math.abs(d));
            result.addCurve(new CircleArc2D(v1, Math.abs(d), circle
                    .getPosition(p0), circle.getPosition(p1), d>0));
        }

        p2 = line.getProjectedPoint(v2);
        line0 = line;

        // ----- Main loop -----

        // Main iteration on vertices
        while (iterator.hasNext()) {
            // Compute line parallel to current line segment
            v1 = v2;
            v2 = iterator.next();
            line = new StraightLine2D(v1, v2).getParallel(d);

            // Check angle of the 2 lines
            if (Angle2D.getAngle(line0, line)>Math.PI^d<0) {
                // Line is going to the right -> add the previous line segment
                // truncated at corner
                p2 = line.getIntersection(line0);
                // TODO: need mode precise control
                result.addCurve(new LineSegment2D(p1, p2));
                p1 = p2;
            } else {
                // line is going to the left -> add the complete line segment
                // and a circle arc
                result.addCurve(new LineSegment2D(p1, p2));
                p1 = line.getProjectedPoint(v1);
                circle = new Circle2D(v1, Math.abs(d));
                result.addCurve(new CircleArc2D(v1, Math.abs(d), circle
                        .getPosition(p2), circle.getPosition(p1), d>0));
            }

            // Prepare for next iteration
            p2 = line.getProjectedPoint(v2);
            line0 = line;
        }

        // ----- Post processing -----

        // current line segment join the last point to the first point
        iterator = polyline.getVertices().iterator();
        v1 = v2;
        v2 = iterator.next();
        line = new StraightLine2D(v1, v2).getParallel(d);

        // Check angle of the 2 lines
        if (Angle2D.getAngle(line0, line)>Math.PI^d<0) {
            // Line is going to the right -> add the previous line segment
            // truncated at corner
            p2 = line.getIntersection(line0);
            // TODO: need mode precise control
            result.addCurve(new LineSegment2D(p1, p2));
            p1 = p2;
        } else {
            // line is going to the left -> add the complete line segment
            // and a circle arc
            result.addCurve(new LineSegment2D(p1, p2));
            p1 = line.getProjectedPoint(v1);
            circle = new Circle2D(v1, Math.abs(d));
            result.addCurve(new CircleArc2D(v1, Math.abs(d), circle
                    .getPosition(p2), circle.getPosition(p1), d>0));
        }

        // Add the last line segment
        result.addCurve(new LineSegment2D(p1, p0));

        // Return the resulting curve
        return result;
    }
FileLine
math/geom2d/curve/CurveArray2D.java511
math/geom2d/curve/CurveSet2D.java510
    public CurveSet2D<? extends Curve2D> getSubCurve(double t0, double t1) {
        // number of curves in the set
        int nc = curves.size();

        // create a new empty curve set
        CurveArray2D<Curve2D> res = new CurveArray2D<Curve2D>();
        Curve2D curve;

        // format to ensure t is between T0 and T1
        t0 = Math.min(Math.max(t0, 0), nc*2-.6);
        t1 = Math.min(Math.max(t1, 0), nc*2-.6);

        // find curves index
        double t0f = Math.floor(t0);
        double t1f = Math.floor(t1);

        // indices of curves supporting points
        int ind0 = (int) Math.floor(t0f/2);
        int ind1 = (int) Math.floor(t1f/2);

        // case of t a little bit after a curve
        if (t0-2*ind0>1.5)
            ind0++;
        if (t1-2*ind1>1.5)
            ind1++;

        // start at the beginning of a curve
        t0f = 2*ind0;
        t1f = 2*ind1;

        double pos0, pos1;

        // need to subdivide only one curve
        if (ind0==ind1&&t0<t1) {
            curve = curves.get(ind0);
            pos0 = Curve2DUtils.fromUnitSegment(t0-t0f, 
            		curve.getT0(), curve.getT1());
            pos1 = Curve2DUtils.fromUnitSegment(t1-t1f, 
            		curve.getT0(), curve.getT1());
            res.addCurve(curve.getSubCurve(pos0, pos1));
            return res;
        }

        // add the end of the curve containing first cut
        curve = curves.get(ind0);
        pos0 = Curve2DUtils.fromUnitSegment(t0-t0f, 
        		curve.getT0(), curve.getT1());
        res.addCurve(curve.getSubCurve(pos0, curve.getT1()));

        if (ind1>ind0) {
            // add all the whole curves between the 2 cuts
            for (int n = ind0+1; n<ind1; n++)
                res.addCurve(curves.get(n));
        } else {
            // add all curves until the end of the set
            for (int n = ind0+1; n<nc; n++)
                res.addCurve(curves.get(n));

            // add all curves from the beginning of the set
            for (int n = 0; n<ind1; n++)
                res.addCurve(curves.get(n));
        }

        // add the beginning of the last cut curve
        curve = curves.get(ind1);
        pos1 = Curve2DUtils.fromUnitSegment(t1-t1f, 
        		curve.getT0(), curve.getT1());
        res.addCurve(curve.getSubCurve(curve.getT0(), pos1));

        // return the curve set
        return res;
    }
FileLine
math/geom2d/line/Polyline2DUtils.java66
math/geom2d/polygon/Polyline2DUtils.java69
        if (polyline instanceof LinearRing2D) {
            // Add eventually a circle arc, and the first line segment.

            // Extract parallel to last edge
            LineSegment2D lastEdge = polyline.getLastEdge();
            line0 = StraightLine2D.createParallel(lastEdge, d);

            v2 = lastEdge.getLastPoint();
            p0 = line0.getProjectedPoint(v2);

            // extract current vertices, and current parallel
            iterator = polyline.getVertices().iterator();
            v1 = iterator.next();
            v2 = iterator.next();
            line = new StraightLine2D(v1, v2).getParallel(d);

            // Check angle of the 2 lines
            p1 = line.getProjectedPoint(v1);
            if (Angle2D.getAngle(line0, line)>Math.PI^d<0) {
                // Line is going to the right -> next line segment will be
                // truncated
                p1 = line.getIntersection(line0);
                p0 = p1;
            } else {
                // line is going to the left -> add a circle arc
                circle = new Circle2D(v1, Math.abs(d));
                result.addCurve(new CircleArc2D(v1, Math.abs(d), circle
                        .getPosition(p0), circle.getPosition(p1), d>0));
            }

            p2 = line.getProjectedPoint(v2);
            line0 = line;
        } else {
            // extract current vertices
            iterator = polyline.getVertices().iterator();
            v1 = iterator.next();
            v2 = iterator.next();

            // current parallel
            line0 = new StraightLine2D(v1, v2).getParallel(d);
            p1 = line0.getProjectedPoint(v1);
            p2 = line0.getProjectedPoint(v2);
        }

        // ----- Main loop -----

        // Main iteration on vertices
        while (iterator.hasNext()) {
            // Compute line parallel to current line segment
            v1 = v2;
            v2 = iterator.next();
            line = new StraightLine2D(v1, v2).getParallel(d);

            // Check angle of the 2 lines
            if (Angle2D.getAngle(line0, line)>Math.PI^d<0) {
                // Line is going to the right -> add the previous line segment
                // truncated at corner
                p2 = line.getIntersection(line0);
                // TODO: need mode precise control
                result.addCurve(new LineSegment2D(p1, p2));
                p1 = p2;
            } else {
                // line is going to the left -> add the complete line segment
                // and a circle arc
                result.addCurve(new LineSegment2D(p1, p2));
                p1 = line.getProjectedPoint(v1);
                circle = new Circle2D(v1, Math.abs(d));
                result.addCurve(new CircleArc2D(v1, Math.abs(d), circle
                        .getPosition(p2), circle.getPosition(p1), d>0));
            }

            // Prepare for next iteration
            p2 = line.getProjectedPoint(v2);
            line0 = line;
        }

        // ----- Post processing -----

        if (polyline instanceof LinearRing2D) {
FileLine
math/geom2d/line/ClosedPolyline2D.java98
math/geom2d/polygon/LinearRing2D.java387
        int indMax = this.getVertexNumber();

        // format to ensure t is between T0 and T1
        t0 = Math.min(Math.max(t0, 0), indMax);
        t1 = Math.min(Math.max(t1, 0), indMax);

        // find curves index
        int ind0 = (int) Math.floor(t0+Shape2D.ACCURACY);
        int ind1 = (int) Math.floor(t1+Shape2D.ACCURACY);

        // need to subdivide only one line segment
        if (ind0==ind1&&t0<t1) {
            // extract limit points
            res.addPoint(this.getPoint(t0));
            res.addPoint(this.getPoint(t1));
            // return result
            return res;
        }

        // add the point corresponding to t0
        res.addPoint(this.getPoint(t0));

        if (ind1>ind0) {
            // add all the whole points between the 2 cuts
            for (int n = ind0+1; n<=ind1; n++)
                res.addPoint(points.get(n));
        } else {
            // add all points until the end of the set
            for (int n = ind0+1; n<indMax; n++)
                res.addPoint(points.get(n));

            // add all points from the beginning of the set
            for (int n = 0; n<=ind1; n++)
                res.addPoint(points.get(n));
        }

        // add the last point
        res.addPoint(this.getPoint(t1));

        // return the curve set
        return res;
    }

    // ===================================================================
    // Methods inherited from interface Shape2D

    /**
     * Return the transformed shape, as a ClosePolyline2D.
     */
    @Override
    public LinearRing2D transform(AffineTransform2D trans) {
FileLine
math/geom2d/line/Polyline2DUtils.java143
math/geom2d/polygon/Polyline2DUtils.java147
        if (polyline instanceof LinearRing2D) {
            // current line segment join the last point to the first point
            iterator = polyline.getVertices().iterator();
            v1 = v2;
            v2 = iterator.next();
            line = new StraightLine2D(v1, v2).getParallel(d);

            // Check angle of the 2 lines
            if (Angle2D.getAngle(line0, line)>Math.PI^d<0) {
                // Line is going to the right -> add the previous line segment
                // truncated at corner
                p2 = line.getIntersection(line0);
                // TODO: need mode precise control
                result.addCurve(new LineSegment2D(p1, p2));
                p1 = p2;
            } else {
                // line is going to the left -> add the complete line segment
                // and a circle arc
                result.addCurve(new LineSegment2D(p1, p2));
                p1 = line.getProjectedPoint(v1);
                circle = new Circle2D(v1, Math.abs(d));
                result.addCurve(new CircleArc2D(v1, Math.abs(d), circle
                        .getPosition(p2), circle.getPosition(p1), d>0));
            }

            // Add the last line segment
            result.addCurve(new LineSegment2D(p1, p0));
        } else {
            // Add the last line segment
            result.addCurve(new LineSegment2D(p1, p2));
        }

        // Return the resulting curve
        return result;
    }

    /**
     * Creates a curve parallel to the given polyline, at a distance d. The
     * resulting curve is continuous, but can self-intersect. It is composed of
     * line segments, and circle arcs.
     * 
     * @param polyline the source curve
     * @param d the signed distance between the original curve and its parallel
     * @return the curve parallel to the original curve at a distance d
     */
    public final static BoundaryPolyCurve2D<SmoothOrientedCurve2D>
    createClosedParallel(LinearRing2D polyline, double d) {
FileLine
math/geom2d/spline/BezierCurve2D.java64
math/geom2d/spline/CubicBezierCurve2D.java73
    public CubicBezierCurve2D(double[][] coefs) {
        this(coefs[0][0], coefs[1][0], coefs[0][0]+coefs[0][1]/3.0, coefs[1][0]
                +coefs[1][1]/3.0,
                coefs[0][0]+2*coefs[0][1]/3.0+coefs[0][2]/3.0, coefs[1][0]+2
                        *coefs[1][1]/3.0+coefs[1][2]/3.0, coefs[0][0]
                        +coefs[0][1]+coefs[0][2]+coefs[0][3], coefs[1][0]
                        +coefs[1][1]+coefs[1][2]+coefs[1][3]);
    }

    /**
     * Build a new Bezier curve of degree 3 by specifying position of extreme
     * points and position of 2 control points. The resulting curve is totally
     * contained in the convex polygon formed by the 4 control points.
     * 
     * @param p1 first point
     * @param ctrl1 first control point
     * @param ctrl2 second control point
     * @param p2 last point
     */
    public CubicBezierCurve2D(java.awt.geom.Point2D p1, java.awt.geom.Point2D ctrl1,
FileLine
math/geom2d/spline/CubicBezierCurve2D.java196
math/geom2d/spline/QuadBezierCurve2D.java165
        tab[1][2] = y2-2*ctrly+y1;
        return tab;
    }

    // ===================================================================
    // methods from OrientedCurve2D interface

    /**
     * Use winding angle of approximated polyline
     * 
     * @see math.geom2d.domain.OrientedCurve2D#getWindingAngle(java.awt.geom.Point2D)
     */
    public double getWindingAngle(java.awt.geom.Point2D point) {
        return this.getAsPolyline(100).getWindingAngle(point);
    }

    /**
     * return true if the point is 'inside' the domain bounded by the curve.
     * Uses a polyline approximation.
     * 
     * @param pt a point in the plane
     * @return true if the point is on the left side of the curve.
     */
    public boolean isInside(java.awt.geom.Point2D pt) {
        return this.getAsPolyline(100).isInside(pt);
    }

    public double getSignedDistance(java.awt.geom.Point2D point) {
        if (isInside(point))
            return -getDistance(point.getX(), point.getY());
        else
            return getDistance(point.getX(), point.getY());
    }

    /**
     * @see math.geom2d.domain.OrientedCurve2D#getSignedDistance(java.awt.geom.Point2D)
     */
    public double getSignedDistance(double x, double y) {
        if (isInside(new Point2D(x, y)))
            return -getDistance(x, y);
        else
            return getDistance(x, y);
    }

    // ===================================================================
    // methods from SmoothCurve2D interface

    public Vector2D getTangent(double t) {
        double[][] c = getParametric();
        double dx = c[0][1]+2*c[0][2]*t;
FileLine
math/geom2d/spline/BezierCurve2D.java186
math/geom2d/spline/CubicBezierCurve2D.java520
        CubicBezierCurve2D bezier = (CubicBezierCurve2D) obj;
        
        // compare each field
        if(Math.abs(this.x1-bezier.x1)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.y1-bezier.y1)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.ctrlx1-bezier.ctrlx1)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.ctrly1-bezier.ctrly1)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.ctrlx2-bezier.ctrlx2)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.ctrly2-bezier.ctrly2)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.x2-bezier.x2)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.y2-bezier.y2)>Shape2D.ACCURACY) return false;
        
        return true;
    }
    
    @Override
    public CubicBezierCurve2D clone() {
FileLine
math/geom2d/line/Polyline2DUtils.java70
math/geom2d/line/Polyline2DUtils.java220
        LineSegment2D lastEdge = polyline.getLastEdge();
        line0 = StraightLine2D.createParallel(lastEdge, d);

        v2 = lastEdge.getLastPoint();
        p0 = line0.getProjectedPoint(v2);

        // extract current vertices, and current parallel
        iterator = polyline.getVertices().iterator();
        v1 = iterator.next();
        v2 = iterator.next();
        line = new StraightLine2D(v1, v2).getParallel(d);

        // Check angle of the 2 lines
        p1 = line.getProjectedPoint(v1);
        if (Angle2D.getAngle(line0, line)>Math.PI^d<0) {
            // Line is going to the right -> next line segment will be
            // truncated
            p1 = line.getIntersection(line0);
            p0 = p1;
        } else {
            // line is going to the left -> add a circle arc
            circle = new Circle2D(v1, Math.abs(d));
            result.addCurve(new CircleArc2D(v1, Math.abs(d), circle
                    .getPosition(p0), circle.getPosition(p1), d>0));
        }

        p2 = line.getProjectedPoint(v2);
        line0 = line;
FileLine
math/geom2d/curve/Curve2DUtils.java398
math/geom2d/domain/Boundary2DUtils.java284
                res.addCurve(box.getAsRectangle().getBoundary().getFirstCurve());
        }

        // return the result
        return res;
    }

    public final static int findNextCurveIndex(double[] positions, double pos) {
        int ind = -1;
        double posMin = java.lang.Double.MAX_VALUE;
        for (int i = 0; i<positions.length; i++) {
            // avoid NaN
            if (java.lang.Double.isNaN(positions[i]))
                continue;
            // avoid values before
            if (positions[i]-pos<Shape2D.ACCURACY)
                continue;

            // test if closer that other points
            if (positions[i]<posMin) {
                ind = i;
                posMin = positions[i];
            }
        }

        if (ind!=-1)
            return ind;

        // if not found, return index of smallest value (mean that pos is last
        // point on the boundary, so we need to start at the beginning).
        for (int i = 0; i<positions.length; i++) {
            if (java.lang.Double.isNaN(positions[i]))
                continue;
            if (positions[i]-posMin<Shape2D.ACCURACY) {
                ind = i;
                posMin = positions[i];
            }
        }
        return ind;
    }

    /**
     * Extracts a portion of the boundary of a bounded box.
     * 
     * @param box the box from which one extract a portion of boundary
     * @param p0 the first point of the portion
     * @param p1 the last point of the portion
     * @return the portion of the bounding box boundary as a Polyline2D
     */
    public final static Polyline2D getBoundaryPortion(Box2D box, Point2D p0,
FileLine
math/geom2d/curve/CurveArray2D.java345
math/geom2d/curve/CurveSet2D.java367
    public Point2D getPoint(double t) {
        if (curves.size()==0)
            return null;
        if (t<getT0())
            return this.getFirstCurve().getFirstPoint();
        if (t>getT1())
            return this.getLastCurve().getLastPoint();

        // curve index
        int nc = (int) Math.floor(t);

        // check index if even-> corresponds to a curve
        int indc = (int) Math.floor(nc/2);
        if (indc*2==nc) {
            Curve2D curve = curves.get(indc);
            double pos = Curve2DUtils.fromUnitSegment(t-nc, 
            		curve.getT0(), curve.getT1());
            return curve.getPoint(pos);
        } else {
            // return either last point of preceding curve,
            // or first point of next curve
            if (t-nc<.5)
                return curves.get(indc).getLastPoint();
            else
                return curves.get(indc+1).getFirstPoint();
        }
    }
FileLine
math/geom2d/conic/CircleArc2D.java306
math/geom2d/conic/EllipseArc2D.java211
        Point2D p2 = getPoint(Math.abs(angleExtent));

        // compute angle of point with extreme points
        double angle1 = Angle2D.getHorizontalAngle(point, p1);
        double angle2 = Angle2D.getHorizontalAngle(point, p2);

        // test on which 'side' of the arc the point lie
        boolean b1 = (new StraightLine2D(p1, p2)).isInside(point);
        boolean b2 = ellipse.isInside(point);

        if (angleExtent>0) {
            if (b1||b2) { // inside of ellipse arc
                if (angle2>angle1)
                    return angle2-angle1;
                else
                    return 2*Math.PI-angle1+angle2;
            } else { // outside of ellipse arc
                if (angle2>angle1)
                    return angle2-angle1-2*Math.PI;
                else
                    return angle2-angle1;
            }
        } else {
            if (!b1||b2) {
                if (angle1>angle2)
                    return angle2-angle1;
                else
                    return angle2-angle1-2*Math.PI;
            } else {
                if (angle1>angle2)
                    return angle2-angle1+2*Math.PI;
                else
                    return angle2-angle1;
            }
            // if(b1 || b2){
            // if(angle1>angle2) return angle1 - angle2;
            // else return 2*Math.PI - angle2 + angle1;
            // }else{
            // if(angle1>angle2) return angle1 - angle2 - 2*Math.PI;
            // else return angle1 - angle2;
            // }
        }
    }
FileLine
math/geom2d/line/Polyline2DUtils.java145
math/geom2d/line/Polyline2DUtils.java283
        iterator = polyline.getVertices().iterator();
        v1 = v2;
        v2 = iterator.next();
        line = new StraightLine2D(v1, v2).getParallel(d);

        // Check angle of the 2 lines
        if (Angle2D.getAngle(line0, line)>Math.PI^d<0) {
            // Line is going to the right -> add the previous line segment
            // truncated at corner
            p2 = line.getIntersection(line0);
            result.addCurve(new LineSegment2D(p1, p2));
            p1 = p2;
        } else {
            // line is going to the left -> add the complete line segment
            // and a circle arc
            result.addCurve(new LineSegment2D(p1, p2));
            p1 = line.getProjectedPoint(v1);
            circle = new Circle2D(v1, Math.abs(d));
            result.addCurve(new CircleArc2D(v1, Math.abs(d), circle
                    .getPosition(p2), circle.getPosition(p1), d>0));
        }

        // Add the last line segment
        result.addCurve(new LineSegment2D(p1, p0));
FileLine
math/geom2d/line/Polyline2DUtils.java113
math/geom2d/line/Polyline2DUtils.java252
        while (iterator.hasNext()) {
            // Compute line parallel to current line segment
            v1 = v2;
            v2 = iterator.next();
            line = new StraightLine2D(v1, v2).getParallel(d);

            // Check angle of the 2 lines
            if (Angle2D.getAngle(line0, line)>Math.PI^d<0) {
                // Line is going to the right -> add the previous line segment
                // truncated at corner
                p2 = line.getIntersection(line0);
                result.addCurve(new LineSegment2D(p1, p2));
                p1 = p2;
            } else {
                // line is going to the left -> add the complete line segment
                // and a circle arc
                result.addCurve(new LineSegment2D(p1, p2));
                p1 = line.getProjectedPoint(v1);
                circle = new Circle2D(v1, Math.abs(d));
                result.addCurve(new CircleArc2D(v1, Math.abs(d), circle
                        .getPosition(p2), circle.getPosition(p1), d>0));
            }

            // Prepare for next iteration
            p2 = line.getProjectedPoint(v2);
            line0 = line;
        }
FileLine
math/geom2d/conic/Ellipse2D.java224
math/geom2d/conic/Hyperbola2D.java146
    public static Hyperbola2D reduceCentered(double[] coefs) {
        double A = coefs[0];
        double B = coefs[1];
        double C = coefs[2];

        // Compute orientation angle of the hyperbola
        double theta;
        if (Math.abs(A-C)<Shape2D.ACCURACY) {
            theta = Math.PI/4;
        } else {
            theta = Math.atan2(B, (A-C))/2.0;
            if (B<0)
                theta -= Math.PI;
            theta = Angle2D.formatAngle(theta);
        }

        // compute ellipse in isothetic basis
        double[] coefs2 = Conic2DUtils.transformCentered(coefs,
                AffineTransform2D.createRotation(-theta));

        // extract coefficient f if present
        double f = 1;
        if (coefs2.length>5)
            f = Math.abs(coefs[5]);

        assert Math.abs(coefs2[1]/f)<Shape2D.ACCURACY :
        	"Second conic coefficient should be zero";
FileLine
math/geom2d/line/InvertedRay2D.java136
math/geom2d/line/Ray2D.java144
    	return new Ray2D(origin, target);
    }
    
    /**
     * @deprecated lines will become immutable in a future release
     */
    @Deprecated
    public void setRay(double x0, double y0, double dx, double dy) {
        this.x0 = x0;
        this.y0 = y0;
        this.dx = dx;
        this.dy = dy;
    }

    /**
     * @deprecated lines will become immutable in a future release
     */
    @Deprecated
    public void setRay(Point2D p1, Point2D p2) {
        this.x0 = p1.getX();
        this.y0 = p1.getY();
        this.dx = p2.getX()-this.x0;
        this.dy = p2.getY()-this.y0;
    }

    /**
     * @deprecated lines will become immutable in a future release
     */
    @Deprecated
    public void setRay(Point2D point, Vector2D vect) {
        this.x0 = point.getX();
        this.y0 = point.getY();
        this.dx = vect.getX();
        this.dy = vect.getY();
    }


    // ===================================================================
    // methods implementing the CirculinearCurve2D interface

	/* (non-Javadoc)
	 * @see math.geom2d.circulinear.CirculinearCurve2D#getParallel(double)
	 */
	public Ray2D getParallel(double d) {
FileLine
math/geom2d/polygon/HRectangle2D.java198
math/geom2d/polygon/Rectangle2D.java318
    }

    public double getDistance(java.awt.geom.Point2D p) {
        return Math.max(getSignedDistance(p.getX(), p.getY()), 0);
    }

    public double getDistance(double x, double y) {
        return Math.max(getSignedDistance(x, y), 0);
    }

    /**
     * Get the signed distance of the shape to the given point : this distance
     * is positive if the point lies outside the shape, and is negative if the
     * point lies inside the shape. In this case, absolute value of distance is
     * equals to the distance to the border of the shape.
     */
    public double getSignedDistance(java.awt.geom.Point2D p) {
        return getSignedDistance(p.getX(), p.getY());
    }

    /**
     * Get the signed distance of the shape to the given point : this distance
     * is positive if the point lies outside the shape, and is negative if the
     * point lies inside the shape. In this case, absolute value of distance is
     * equals to the distance to the border of the shape.
     */
    public double getSignedDistance(double x, double y) {
        double dist = getBoundary().getDistance(x, y);
        if (contains(x, y))
            return -dist;
        else
            return dist;
    }

    /**
     * Return the clipped polygon.
     */
    public Domain2D clip(Box2D box) {
FileLine
math/geom2d/line/Polyline2DUtils.java115
math/geom2d/polygon/Polyline2DUtils.java291
            v1 = v2;
            v2 = iterator.next();
            line = new StraightLine2D(v1, v2).getParallel(d);

            // Check angle of the 2 lines
            if (Angle2D.getAngle(line0, line)>Math.PI^d<0) {
                // Line is going to the right -> add the previous line segment
                // truncated at corner
                p2 = line.getIntersection(line0);
                result.addCurve(new LineSegment2D(p1, p2));
                p1 = p2;
            } else {
                // line is going to the left -> add the complete line segment
                // and a circle arc
                result.addCurve(new LineSegment2D(p1, p2));
                p1 = line.getProjectedPoint(v1);
                circle = new Circle2D(v1, Math.abs(d));
                result.addCurve(new CircleArc2D(v1, Math.abs(d), circle
                        .getPosition(p2), circle.getPosition(p1), d>0));
            }
FileLine
math/geom2d/circulinear/CirculinearBoundarySet2D.java80
math/geom2d/circulinear/CirculinearCurveSet2D.java63
    public CirculinearCurveSet2D(Collection<? extends T> curves) {
    	this.curves = new ArrayList<T>(curves.size());
        this.curves.addAll(curves);
    }

    
    // ===================================================================
    // static methods

    // OFFENDING DECLATAIONS ...
//    /**
//     * Static factory for creating a new CirculinearCurveSet2D from a collection of
//     * curves.
//     * @since 0.8.1
//     */
//    public static <T extends CirculinearCurve2D> CirculinearCurveSet2D<T> create(
//    		Collection<T> curves) {
//    	return new CirculinearCurveSet2D<T>(curves);
//    }
//    
//    /**
//     * Static factory for creating a new CirculinearCurveSet2D from an array of
//     * curves.
//     * @since 0.8.1
//     */
//    public static <T extends CirculinearCurve2D> CirculinearCurveSet2D<T> create(
//    		T[] curves) {
//    	return new CirculinearCurveSet2D<T>(curves);
//    }

    
    // ===================================================================
    // methods implementing the CirculinearCurve2D interface

	/* (non-Javadoc)
	 * @see math.geom2d.circulinear.CirculinearCurve2D#getLength()
	 */
	public double getLength() {
		double sum = 0;
		for(CirculinearCurve2D curve : this.getCurves())
			sum += curve.getLength();
		return sum;
	}

	/* (non-Javadoc)
	 * @see math.geom2d.circulinear.CirculinearCurve2D#getLength(double)
	 */
	public double getLength(double pos) {
		return CirculinearCurve2DUtils.getLength(this, pos);
	}

	/* (non-Javadoc)
	 * @see math.geom2d.circulinear.CirculinearCurve2D#getPosition(double)
	 */
	public double getPosition(double length) {
		return CirculinearCurve2DUtils.getPosition(this, length);
	}

	/* (non-Javadoc)
	 * @see math.geom2d.circulinear.CirculinearShape2D#getBuffer(double)
	 */
	public CirculinearDomain2D getBuffer(double dist) {
		return CirculinearCurve2DUtils.computeBuffer(this, dist);
	}

	/* (non-Javadoc)
	 * @see math.geom2d.circulinear.CirculinearContinuousCurve2D#getParallel(double)
	 */
	public CirculinearCurve2D getParallel(double d) {
		return CirculinearCurve2DUtils.createParallel(this, d);
	}
	
	/* (non-Javadoc)
	 * @see math.geom2d.circulinear.CirculinearCurve2D#transform(math.geom2d.transform.CircleInversion2D)
	 */
	public CirculinearCurveSet2D<CirculinearCurve2D> transform(CircleInversion2D inv) {
FileLine
math/geom2d/spline/QuadBezier2D.java177
math/geom2d/spline/QuadBezierCurve2D.java462
        QuadBezierCurve2D bezier = (QuadBezierCurve2D) obj;
        
        // Compare each field
        if(Math.abs(this.x1-bezier.x1)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.y1-bezier.y1)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.ctrlx-bezier.ctrlx)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.ctrly-bezier.ctrly)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.x2-bezier.x2)>Shape2D.ACCURACY) return false;
        if(Math.abs(this.y2-bezier.y2)>Shape2D.ACCURACY) return false;
        
        return true;
    }
    
	@Override
    public QuadBezierCurve2D clone() {
FileLine
math/geom2d/spline/CubicBezierCurve2D.java285
math/geom2d/spline/QuadBezierCurve2D.java229
        return (xp*ys-yp*xs)/Math.pow(Math.hypot(xp, yp), 3);
    }

    // ===================================================================
    // methods from ContinousCurve2D interface

    /**
     * The cubic curve is never closed.
     */
    public boolean isClosed() {
        return false;
    }

    // ===================================================================
    // methods from Curve2D interface

    /**
     * Returns 0, as Bezier curve is parametrized between 0 and 1.
     */
    public double getT0() {
        return 0;
    }

    /**
     * Returns 1, as Bezier curve is parametrized between 0 and 1.
     */
    public double getT1() {
        return 1;
    }

    /**
     * Use approximation, by replacing Bezier curve with a polyline.
     * 
     * @see math.geom2d.curve.Curve2D#getIntersections(math.geom2d.line.LinearShape2D)
     */
    public Collection<Point2D> getIntersections(LinearShape2D line) {
        return this.getAsPolyline(100).getIntersections(line);
    }

    /**
     * @see math.geom2d.curve.Curve2D#getPoint(double)
     */
    public Point2D getPoint(double t) {
        t = Math.min(Math.max(t, 0), 1);
        double[][] c = getParametric();
        double x = c[0][0]+(c[0][1]+c[0][2]*t)*t;
FileLine
math/geom2d/spline/CubicBezierCurve2D.java331
math/geom2d/spline/QuadBezierCurve2D.java275
        double y = c[1][0]+(c[1][1]+c[1][2]*t)*t;
        return new Point2D(x, y);
    }

    /**
     * Get the first point of the curve.
     * 
     * @return the first point of the curve
     */
	@Override
    public Point2D getFirstPoint() {
        return new Point2D(this.x1, this.y1);
    }

    /**
     * Get the last point of the curve.
     * 
     * @return the last point of the curve.
     */
	@Override
    public Point2D getLastPoint() {
        return new Point2D(this.x2, this.y2);
    }

    /**
     * Compute position by approximating cubic spline with a polyline.
     */
    public double getPosition(java.awt.geom.Point2D point) {
        int N = 100;
        return this.getAsPolyline(N).getPosition(point)/(N);
    }

    /**
     * Compute position by approximating cubic spline with a polyline.
     */
    public double project(java.awt.geom.Point2D point) {
        int N = 100;
        return this.getAsPolyline(N).project(point)/(N);
    }

    /**
     * Returns the bezier curve given by control points taken in reverse order.
     */
    public QuadBezierCurve2D getReverseCurve() {
FileLine
math/geom2d/spline/CubicBezierCurve2D.java404
math/geom2d/spline/QuadBezierCurve2D.java357
				x1, y1, ctrlx, ctrly, x2, y2).contains(x, y);
	}

	/* (non-Javadoc)
	 * @see math.geom2d.Shape2D#contains(java.awt.geom.Point2D)
	 */
	public boolean contains(java.awt.geom.Point2D p) {
		return this.contains(p.getX(), p.getY());
	}

	/**
     * @see math.geom2d.Shape2D#getDistance(java.awt.geom.Point2D)
     */
    public double getDistance(java.awt.geom.Point2D p) {
        return this.getDistance(p.getX(), p.getY());
    }

    /**
     * Compute approximated distance, computed on a polyline.
     * 
     * @see math.geom2d.Shape2D#getDistance(double, double)
     */
    public double getDistance(double x, double y) {
        return this.getAsPolyline(100).getDistance(x, y);
    }

    /**
     * return true, a cubic Bezier Curve is always bounded.
     */
    public boolean isBounded() {
        return true;
    }

    public boolean isEmpty() {
        return false;
    }

    /**
     * Clip the circle arc by a box. The result is an instance of
     * ContinuousOrientedCurveSet2D<QuadBezierCurve2D>, which contains only
     * instances of EllipseArc2D. If the ellipse arc is not clipped, the result
     * is an instance of ContinuousOrientedCurveSet2D<QuadBezierCurve2D>
     * which contains 0 curves.
     */
    public CurveSet2D<? extends QuadBezierCurve2D> clip(Box2D box) {
FileLine
math/geom2d/curve/CurveArray2D.java472
math/geom2d/curve/CurveSet2D.java473
    public double project(java.awt.geom.Point2D point) {
        double minDist = Double.MAX_VALUE, dist = minDist;
        double x = point.getX(), y = point.getY();
        double pos = 0, t0, t1;

        int i = 0;
        for (Curve2D curve : curves) {
            dist = curve.getDistance(x, y);
            if (dist<minDist) {
                minDist = dist;
                pos = curve.project(point);
                // format position
                t0 = curve.getT0();
                t1 = curve.getT1();
                pos = Curve2DUtils.toUnitSegment(pos, t0, t1)+i*2;
            }
            i++;
        }
        return pos;
    }
FileLine
math/geom2d/curve/CurveArray2D.java450
math/geom2d/curve/CurveSet2D.java452
    public double getPosition(java.awt.geom.Point2D point) {
        double minDist = Double.MAX_VALUE, dist = minDist;
        double x = point.getX(), y = point.getY();
        double pos = 0, t0, t1;

        int i = 0;
        for (Curve2D curve : curves) {
            dist = curve.getDistance(x, y);
            if (dist<minDist) {
                minDist = dist;
                pos = curve.getPosition(point);
                // format position
                t0 = curve.getT0();
                t1 = curve.getT1();
                pos = Curve2DUtils.toUnitSegment(pos, t0, t1)+i*2;
            }
            i++;
        }
        return pos;
    }
FileLine
math/geom2d/curve/Curve2DUtils.java67
math/geom2d/curve/CurveSet2D.java100
    protected final static double fromUnitSegment(double t, double t0, double t1) {
        if (t<=0)
            return t0;
        if (t>=1)
            return t1;

        if (t0==Double.NEGATIVE_INFINITY&&t1==Double.POSITIVE_INFINITY)
            return Math.tan((t-.5)*Math.PI);

        if (t0==Double.NEGATIVE_INFINITY)
            return Math.tan((t-1)*Math.PI/2)+t1;

        if (t1==Double.POSITIVE_INFINITY)
            return Math.tan(t*Math.PI/2)+t0;

        // t0 and t1 are both finite
        return t*(t1-t0)+t0;
    }
FileLine
math/geom2d/curve/Curve2DUtils.java39
math/geom2d/curve/CurveSet2D.java70
    protected final static double toUnitSegment(double t, double t0, double t1) {
        if (t<=t0)
            return 0;
        if (t>=t1)
            return 1;

        if (t0==Double.NEGATIVE_INFINITY&&t1==Double.POSITIVE_INFINITY)
            return Math.atan(t)/Math.PI+.5;

        if (t0==Double.NEGATIVE_INFINITY)
            return Math.atan(t-t1)*2/Math.PI+1;

        if (t1==Double.POSITIVE_INFINITY)
            return Math.atan(t-t0)*2/Math.PI;

        // t0 and t1 are both finite
        return (t-t0)/(t1-t0);
    }
FileLine
math/geom2d/curve/CurveArray2D.java627
math/geom2d/curve/CurveSet2D.java621
    public Box2D getBoundingBox() {
        double xmin = Double.MAX_VALUE;
        double ymin = Double.MAX_VALUE;
        double xmax = Double.MIN_VALUE;
        double ymax = Double.MIN_VALUE;

        Box2D box;
        for (Curve2D curve : curves) {
            box = curve.getBoundingBox();
            xmin = Math.min(xmin, box.getMinX());
            ymin = Math.min(ymin, box.getMinY());
            xmax = Math.max(xmax, box.getMaxX());
            ymax = Math.max(ymax, box.getMaxY());
        }

        return new Box2D(xmin, xmax, ymin, ymax);
    }
FileLine
math/geom2d/spline/QuadBezier2D.java64
math/geom2d/spline/QuadBezierCurve2D.java72
    public QuadBezierCurve2D(double[][] coefs) {
        this(coefs[0][0], coefs[1][0], coefs[0][0]+coefs[0][1]/2.0, coefs[1][0]
                +coefs[1][1]/2.0, coefs[0][0]+coefs[0][1]+coefs[0][2],
                coefs[1][0]+coefs[1][1]+coefs[1][2]);
    }

    /**
     * Build a new quadratic Bezier curve by specifying position of extreme
     * points and position of control point. The resulting curve is totally
     * contained in the convex polygon formed by the 3 control points.
     * 
     * @param p1 first point
     * @param ctrl control point
     * @param p2 last point
     */
    public QuadBezierCurve2D(java.awt.geom.Point2D p1, java.awt.geom.Point2D ctrl,
FileLine
math/geom2d/spline/BezierCurve2D.java99
math/geom2d/spline/CubicBezierCurve2D.java107
    public CubicBezierCurve2D(
    		java.awt.geom.Point2D p1, Vector2D v1,
            java.awt.geom.Point2D p2, Vector2D v2) {
        this(	p1.getX(), p1.getY(), 
        		p1.getX()+v1.getX()/3, p1.getY()+v1.getY()/3,
        		p2.getX()-v2.getX()/3, p2.getY()-v2.getY()/3,
        		p2.getX(), p2.getY());
    }

    /**
     * Build a new Bezier curve of degree 3 by specifying position of extreme
     * points and position of 2 control points. The resulting curve is totally
     * containe in the convex polygon formed by the 4 control points.
     */
    public CubicBezierCurve2D(double x1, double y1, double xctrl1, double yctrl1,
FileLine
math/geom2d/polygon/HRectangle2D.java141
math/geom2d/polygon/Rectangle2D.java243
        edges.add(new LineSegment2D(x3, y3, x0, y0));
        return edges;
    }

    public int getEdgeNumber() {
        return 4;
    }

    /* (non-Javadoc)
     * @see math.geom2d.polygon.Polygon2D#getRings()
     */
    public Collection<LinearRing2D> getRings() {
        ArrayList<LinearRing2D> rings = new ArrayList<LinearRing2D>(1);
        rings.add(new LinearRing2D(this.getVertices()));
        return rings;
    }

	// ===================================================================
    // methods inherited from Domain2D interface

	/* (non-Javadoc)
	 * @see math.geom2d.circulinear.CirculinearDomain2D#transform(math.geom2d.transform.CircleInversion2D)
	 */
	public CirculinearDomain2D transform(CircleInversion2D inv) {
		return new GenericCirculinearDomain2D(
				this.getBoundary().transform(inv));
	}

	/* (non-Javadoc)
	 * @see math.geom2d.circulinear.CirculinearShape2D#getBuffer(double)
	 */
	public CirculinearDomain2D getBuffer(double dist) {
		return CirculinearCurve2DUtils.computeBuffer(
				this.getBoundary(), dist);
	}

	
    // ===================================================================
    // methods inherited from interface Domain2D

   public CirculinearBoundarySet2D<LinearRing2D> getBoundary() {
FileLine
math/geom2d/conic/Ellipse2D.java888
math/geom2d/conic/Ellipse2D.java923
    public double project(java.awt.geom.Point2D point) {
        double xp = point.getX();
        double yp = point.getY();

        // translate
        xp = xp-this.xc;
        yp = yp-this.yc;

        // rotate
        double xp1 = xp*Math.cos(theta)+yp*Math.sin(theta);
        double yp1 = -xp*Math.sin(theta)+yp*Math.cos(theta);
        xp = xp1;
        yp = yp1;

        // scale
        xp = xp/this.r1;
        yp = yp/this.r2;