class PlanarCurve {

	public double getMinimumDistanceToCurve(final PlanarCurve curve)
	{
		List<Pair<PlanarCurveSegment, PlanarCurveSegment>> combined = combineCurves(segments, curve.getSegments());
		
		double min = combined.get(0).getFirst().getPos().distanceTo(combined.get(0).getSecond().getPos());
		
		for (Pair<PlanarCurveSegment, PlanarCurveSegment> part : combined)
		{
			double tStart = part.getFirst().getStartTime();
			double tEnd = part.getFirst().getEndTime();
			
			List<Double> roots = minDistanceRoots(part.getFirst(), part.getSecond());
			roots.add(tEnd - tStart);
			
			double dist = roots.stream()
					.filter(r -> (r > 0) && (r <= (tEnd - tStart)))
					.mapToDouble(r -> part.getFirst().getPosition(r).distanceTo(part.getSecond().getPosition(r)))
					.min().orElse(Double.POSITIVE_INFINITY);
			
			if (dist < min)
			{
				min = dist;
			}
		}
		return min;
	}

	public  PlanarCurve(final List<PlanarCurveSegment> segments);

}