CPD Results
The following document contains the results of PMD's CPD 7.3.0.
Duplications
File |
Line |
org/djutils/draw/line/Clothoid.java |
642 |
org/djutils/draw/line/Clothoid.java |
732 |
double dx = x1 - x0;
double dy = y1 - y0;
double r = Math.hypot(dx, dy);
double phi = Math.atan2(dy, dx);
double phi0 = theta0 - phi;
double phi1 = theta1 - phi;
phi0 -= m_2pi * Math.rint(phi0 / m_2pi);
phi1 -= m_2pi * Math.rint(phi1 / m_2pi);
if (phi0 > m_pi)
{
phi0 -= m_2pi;
}
if (phi0 < -m_pi)
{
phi0 += m_2pi;
}
if (phi1 > m_pi)
{
phi1 -= m_2pi;
}
if (phi1 < -m_pi)
{
phi1 += m_2pi;
}
double delta = phi1 - phi0;
// punto iniziale
double x = phi0 * m_1_pi;
double y = phi1 * m_1_pi;
double xy = x * y;
y *= y;
x *= x;
double a =
(phi0 + phi1) * (CF[0] + xy * (CF[1] + xy * CF[2]) + (CF[3] + xy * CF[4]) * (x + y) + CF[5] * (x * x + y * y));
// newton
double g = 0;
double dg;
double[] intC = new double[3];
double[] intS = new double[3];
int niter = 0;
do
{
GeneralizedFresnelCS(3, 2 * a, delta - a, phi0, intC, intS);
g = intS[0];
dg = intC[2] - intC[1];
a -= g / dg;
}
while (++niter <= 10 && Math.abs(g) > 1E-12);
Throw.when(Math.abs(g) > 1E-8, DrawRuntimeException.class, "Newton did not converge, g = " + g + " niter = " + niter); |
File |
Line |
org/djutils/draw/line/Bezier.java |
377 |
org/djutils/draw/line/Bezier.java |
747 |
Point2d projectedPoint = medianPoint.closestPointOnSegment(prevPoint, nextPoint);
double errorPosition = medianPoint.distance(projectedPoint);
if (errorPosition >= epsilon)
{
// We need to insert another point
result.put(medianT, medianPoint);
continue;
}
if (prevPoint.distance(nextPoint) > epsilon)
{
// Check for an inflection point by creating additional points at one quarter and three quarters. If these
// are on opposite sides of the line from prevPoint to nextPoint; there must be an inflection point.
// https://stackoverflow.com/questions/1560492/how-to-tell-whether-a-point-is-to-the-right-or-left-side-of-a-line
double quarterT = (prevT + medianT) / 2;
double quarterX = Bn(quarterT, px);
double quarterY = Bn(quarterT, py);
int sign1 = (int) Math.signum((nextPoint.x - prevPoint.x) * (quarterY - prevPoint.y)
- (nextPoint.y - prevPoint.y) * (quarterX - prevPoint.x));
double threeQuarterT = (nextT + medianT) / 2;
double threeQuarterX = Bn(threeQuarterT, px);
double threeQuarterY = Bn(threeQuarterT, py);
int sign2 = (int) Math.signum((nextPoint.x - prevPoint.x) * (threeQuarterY - prevPoint.y)
- (nextPoint.y - prevPoint.y) * (threeQuarterX - prevPoint.x));
if (sign1 != sign2)
{ |
File |
Line |
org/djutils/draw/line/PolyLine2d.java |
1134 |
org/djutils/draw/line/PolyLine3d.java |
958 |
List<Point2d> pointList = new ArrayList<>();
int indexInStart = 0;
int indexInEnd = 0;
while (indexInStart < this.size() && indexInEnd < endLine.size())
{
double fractionInStart = lengthAtIndex(indexInStart) / this.length;
double fractionInEnd = endLine.lengthAtIndex(indexInEnd) / endLine.length;
if (fractionInStart < fractionInEnd)
{
pointList.add(get(indexInStart).interpolate(endLine.getLocation(fractionInStart * endLine.length),
transition.function(fractionInStart)));
indexInStart++;
}
else if (fractionInStart > fractionInEnd)
{
pointList.add(this.getLocation(fractionInEnd * this.length).interpolate(endLine.get(indexInEnd),
transition.function(fractionInEnd)));
indexInEnd++;
}
else
{
pointList.add(this.get(indexInStart).interpolate(endLine.getLocation(fractionInEnd * endLine.length),
transition.function(fractionInStart)));
indexInStart++;
indexInEnd++;
}
}
return new PolyLine2d(true, pointList); |
File |
Line |
org/djutils/draw/line/PolyLine2d.java |
551 |
org/djutils/draw/line/PolyLine3d.java |
549 |
public static PolyLine2d concatenate(final double tolerance, final PolyLine2d... lines) throws DrawRuntimeException
{
if (0 == lines.length)
{
throw new DrawRuntimeException("Empty argument list");
}
else if (1 == lines.length)
{
return lines[0];
}
int size = lines[0].size();
for (int i = 1; i < lines.length; i++)
{
if (lines[i - 1].getLast().distance(lines[i].getFirst()) > tolerance)
{
throw new DrawRuntimeException(
"Lines are not connected: " + lines[i - 1].getLast() + " to " + lines[i].getFirst() + " distance is "
+ lines[i - 1].getLast().distance(lines[i].getFirst()) + " > " + tolerance);
}
size += lines[i].size() - 1;
} |
File |
Line |
org/djutils/draw/line/PolyLine2d.java |
696 |
org/djutils/draw/line/PolyLine3d.java |
724 |
point.y - (this.y[index - 1] + fraction * (this.y[index] - this.y[index - 1])));
if (distance < bestDistanceExtended && (fraction >= 0.0 && fraction <= 1.0 || (fraction < 0.0 && index == 1)
|| fraction > 1.0 && index == this.size() - 1))
{
bestDistanceExtended = distance;
}
if (distance < bestDistance && (fraction >= 0.0 || index == 1 && limitHandling != null && !limitHandling)
&& (fraction <= 1.0 || index == this.size() - 1 && limitHandling != null && !limitHandling))
{
bestDistance = distance;
result = lengthAtIndex(index - 1) + fraction * (lengthAtIndex(index) - lengthAtIndex(index - 1));
}
else if (fraction < 0.0 && limitHandling != null && limitHandling)
{
distance = Math.hypot(point.x - this.x[index - 1], point.y - this.y[index - 1]); |
File |
Line |
org/djutils/draw/line/PolyLine2d.java |
466 |
org/djutils/draw/line/PolyLine3d.java |
464 |
Point2d currentPoint = get(index);
if (null != prevPoint && prevPoint.distance(currentPoint) < noiseLevel)
{
if (index == this.size() - 1)
{
if (list.size() > 1)
{
// Replace the last point of the result by the last point of this PolyLine2d
list.set(list.size() - 1, currentPoint);
}
else
{
// Append the last point of this even though it is close to the first point than the noise value to
// comply with the requirement that first and last point of this are ALWAYS included in the result.
list.add(currentPoint);
}
}
continue; // Do not replace prevPoint by currentPoint
}
list.add(currentPoint);
prevPoint = currentPoint;
}
if (list.size() == this.x.length)
{
return this;
}
if (list.size() == 2 && list.get(0).equals(list.get(1)))
{
// Insert point 1 of this; it MUST be different from point 0; so we don't have to test for anything.
list.add(1, get(1));
}
return new PolyLine2d(list); |
File |
Line |
org/djutils/draw/line/PolyLine2d.java |
677 |
org/djutils/draw/line/PolyLine3d.java |
703 |
result = new Ray2d(getLocation(0.0)).projectOrthogonalFractionalExtended(point);
if (null == limitHandling)
{
return result == 0.0 ? 0.0 : Double.NaN;
}
// limitHandling is false
if (result == 0.0)
{
return 0.0;
}
return result > 0 ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY;
}
double bestDistance = Double.POSITIVE_INFINITY;
double bestDistanceExtended = Double.POSITIVE_INFINITY;
for (int index = 1; index < this.size(); index++)
{
double fraction = point.fractionalPositionOnLine(this.x[index - 1], this.y[index - 1], this.x[index], this.y[index], |
File |
Line |
org/djutils/draw/line/PolyLine2d.java |
811 |
org/djutils/draw/line/PolyLine3d.java |
840 |
Point2d toPoint = get(index);
segmentLength = fromPoint.distance(toPoint);
cumulativeLength = nextCumulativeLength;
nextCumulativeLength = cumulativeLength + segmentLength;
if (nextCumulativeLength >= start)
{
break;
}
}
if (start == nextCumulativeLength)
{
pointList.add(get(index));
}
else
{
pointList.add(get(index - 1).interpolate(get(index), (start - cumulativeLength) / segmentLength));
if (end > nextCumulativeLength)
{
pointList.add(get(index));
}
}
while (end > nextCumulativeLength)
{ |
File |
Line |
org/djutils/draw/line/Polygon2d.java |
149 |
org/djutils/draw/line/Polygon3d.java |
170 |
if (firstPoint.x == lastPoint.x && firstPoint.y == lastPoint.y)
{
if (doNotModifyList)
{
result = new ArrayList<>(points.size() - 1);
for (int i = 0; i < points.size() - 1; i++)
{
result.add(points.get(i));
}
}
else
{
result.remove(points.size() - 1);
}
lastPoint = result.get(result.size() - 1);
}
Throw.when(firstPoint.x == lastPoint.x && firstPoint.y == lastPoint.y, DrawRuntimeException.class, |