Beispiel #1
0
double LengthIndexOfPoint::indexOfFromStart(const Coordinate& inputPt, double minIndex) const
{
	double minDistance = numeric_limits<double>::max();

	double ptMeasure = minIndex;
	double segmentStartMeasure = 0.0;
	LineSegment seg;
	LinearIterator it(linearGeom);
	while (it.hasNext())
	{
		if (! it.isEndOfLine())
		{
			seg.p0 = it.getSegmentStart();
			seg.p1 = it.getSegmentEnd();
			double segDistance = seg.distance(inputPt);
			double segMeasureToPt = segmentNearestMeasure(&seg, inputPt, segmentStartMeasure);
			if (segDistance < minDistance
					&& segMeasureToPt > minIndex)
			{
				ptMeasure = segMeasureToPt;
				minDistance = segDistance;
			}
			segmentStartMeasure += seg.getLength();
		}
		it.next();
	}
	return ptMeasure;
}
 Coordinate computePoint(const LineSegment& seg, double dist)
 {
   double dx = seg.p1.x - seg.p0.x;
   double dy = seg.p1.y - seg.p0.y;
   double len = seg.getLength();
   Coordinate pt(dist * dx / len, dist * dy / len);
   pm.makePrecise(pt);
   return pt;
 }
const LineSegment Pose2D::operator/(const LineSegment& lineSegment) const
{
    return LineSegment(*this / lineSegment.getStartPose(), lineSegment.getLength(), lineSegment.getExitAngle());
}