CPD Results

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

Duplications

File Line
org/opentrafficsim/base/geometry/FractionalProjectionHelper.java 552
org/opentrafficsim/base/geometry/RadiusCalculator2d.java 184
return intersectionOrNull(ext, off, a, b);
    }

    /**
     * Intersection of infinite lines (p1->p2) and (p3->p4). Returns null if near-parallel.
     * @param p1 first point of first line
     * @param p2 second point of first line
     * @param p3 first point of second line
     * @param p4 second point of second line
     * @return intersection
     */
    // TODO: can be replaced with djutils version with eps once it is published in djutils
    private static Point2d intersectionOrNull(final Point2d p1, final Point2d p2, final Point2d p3, final Point2d p4)
    {
        final double x1 = p1.x, y1 = p1.y;
        final double x2 = p2.x, y2 = p2.y;
        final double x3 = p3.x, y3 = p3.y;
        final double x4 = p4.x, y4 = p4.y;

        final double dx1 = x2 - x1, dy1 = y2 - y1;
        final double dx2 = x4 - x3, dy2 = y4 - y3;

        final double denom = dx1 * dy2 - dy1 * dx2;
        if (Math.abs(denom) < INTERSECTION_EPS)
        {
            return null; // near-parallel
        }
        final double t = ((x3 - x1) * dy2 - (y3 - y1) * dx2) / denom;
        return new Point2d(x1 + t * dx1, y1 + t * dy1);
    }

    /**
     * Returns intersection for parallel segments, or midpoint fallback when intersection is null or unstable.
     * @param a1 first point of first parallel segment
     * @param a2 second point of first parallel segment
     * @param b1 first point of second parallel segment
     * @param b2 second point of second parallel segment
     * @return intersection
     */
    private static Point2d intersectionOrFallbackMid(final Point2d a1, final Point2d a2, final Point2d b1, final Point2d b2)