/// <summary> /// Returns the <see cref="PointOnPath"/> associated with the supplied <see cref="RndfWayPoint"/>. /// </summary> /// <param name="waypoint"><see cref="RndfWayPoint"/> to find on the path.</param> /// <returns><see cref="PointOnPath"/> instance of <paramref name="waypoint"/>.</returns> /// <remarks> /// The methods does not do any searching but returns the <see cref="PointOnPath"/> object directly. It will put /// the point at the end of a <see cref="PartitionPathSegment"/> if possible or at the beginning if the waypoint /// is the first in the lane. /// </remarks> /// <exception cref="ArgumentException"> /// Throw when the waypoint does not belong to the <see cref="Lane"/> associated with the <see cref="LanePath"/>. /// </exception> public PointOnPath GetWaypointPoint(RndfWayPoint waypoint) { if (!lane.Equals(waypoint.Lane)) { throw new ArgumentException("Waypoint does not belong to the current lane"); } // get the user partition for that stuff if (waypoint.PreviousLanePartition != null) { LanePartition laneParition = waypoint.PreviousLanePartition; PartitionPathSegment pathSeg = GetPathSegment(laneParition.UserPartitions[laneParition.UserPartitions.Count - 1]); return(pathSeg.EndPoint); } else { LanePartition laneParition = waypoint.NextLanePartition; PartitionPathSegment pathSeg = GetPathSegment(laneParition.UserPartitions[0]); return(pathSeg.StartPoint); } }