@@ -175,6 +175,7 @@ public int FindIntersections(
175175 /// <param name="intersections">The buffer for storing each intersection.</param>
176176 /// <param name="orientations">The buffer for storing the orientation of each intersection.</param>
177177 /// <returns>number of intersections hit</returns>
178+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
178179 public int FindIntersectionsWithOrientation (
179180 PointF start ,
180181 PointF end ,
@@ -188,6 +189,24 @@ public int FindIntersectionsWithOrientation(
188189 return 0 ;
189190 }
190191
192+ return this . FindIntersectionsWithOrientationInternal ( start , end , intersections , orientations ) ;
193+ }
194+
195+ /// <summary>
196+ /// Based on a line described by <paramref name="start" /> and <paramref name="end" />
197+ /// populates a buffer for all points on the path that the line intersects.
198+ /// </summary>
199+ /// <param name="start">The start position.</param>
200+ /// <param name="end">The end position.</param>
201+ /// <param name="intersections">The buffer for storing each intersection.</param>
202+ /// <param name="orientations">The buffer for storing the orientation of each intersection.</param>
203+ /// <returns>number of intersections hit</returns>
204+ public int FindIntersectionsWithOrientationInternal (
205+ PointF start ,
206+ PointF end ,
207+ Span < PointF > intersections ,
208+ Span < PointOrientation > orientations )
209+ {
191210 int count = intersections . Length ;
192211
193212 this . ClampPoints ( ref start , ref end ) ;
@@ -813,69 +832,6 @@ private void ClampPoints(ref PointF start, ref PointF end)
813832 }
814833 }
815834
816- /// <summary>
817- /// Calculate any shorter distances along the path.
818- /// </summary>
819- /// <param name="start">The start position.</param>
820- /// <param name="end">The end position.</param>
821- /// <param name="point">The current point.</param>
822- /// <param name="info">The info.</param>
823- /// <returns>
824- /// The <see cref="bool"/>.
825- /// </returns>
826- private bool CalculateShorterDistance ( Vector2 start , Vector2 end , Vector2 point , ref PointInfoInternal info )
827- {
828- Vector2 diffEnds = end - start ;
829-
830- float lengthSquared = diffEnds . LengthSquared ( ) ;
831- Vector2 diff = point - start ;
832-
833- Vector2 multiplied = diff * diffEnds ;
834- float u = ( multiplied . X + multiplied . Y ) / lengthSquared ;
835-
836- if ( u > 1 )
837- {
838- u = 1 ;
839- }
840- else if ( u < 0 )
841- {
842- u = 0 ;
843- }
844-
845- Vector2 multipliedByU = diffEnds * u ;
846-
847- Vector2 pointOnLine = start + multipliedByU ;
848-
849- Vector2 d = pointOnLine - point ;
850-
851- float dist = d . LengthSquared ( ) ;
852-
853- if ( info . DistanceSquared > dist )
854- {
855- info . DistanceSquared = dist ;
856- info . PointOnLine = pointOnLine ;
857- return true ;
858- }
859-
860- return false ;
861- }
862-
863- /// <summary>
864- /// Contains information about the current point.
865- /// </summary>
866- private struct PointInfoInternal
867- {
868- /// <summary>
869- /// The distance squared.
870- /// </summary>
871- public float DistanceSquared ;
872-
873- /// <summary>
874- /// The point on the current line.
875- /// </summary>
876- public PointF PointOnLine ;
877- }
878-
879835 private struct PointData
880836 {
881837 public PointF Point ;
0 commit comments