ios - Point coordinates at given distance on UIBezierPath -


I have a UIBezierPath line and I would like to get the coordinates of a point which is at a certain distance of this line this line From the beginning distance I mean distance with the line.

On the following picture, I am looking for X and Y.

Enter image details here

The correct solution will be a way Which takes distance as an argument and returns the coordinates.

CGPointMyPoint = [Mylly PointEnistence: 53.21]

Is there something like that? I thought this would be a common problem, but no relevant information was found on the web. Maybe I am searching for the wrong thing?

Thank you.

If path is not a curved section, only linear ones, and many paths for one path There are requests, then you can use some preprocessing (first item):

  1 Calculate the length of each segment, and the length of the cumulative path to the end of this segment. Find out the appropriate segments by binary search (or linear search, if the number of the segment is small) 3. Find the parameter (0..1) Relative position of the point in this section 4. Linear of the end points of the segment Calculate the coordinates as a combination.  

Simple example: Enter image details here

< Pre> points (0,0), (1,0), (1,2), (4, -2), (6, -2) length [1, 2, 5, 2] Path lotus length : [0, 1, 3, 8, 10] Distance Area: 5 Binary Search Segment 3 Segment (between 5 and 3 in 5) 3 * (1-T) + 8 * T = 5 Equation) t = 0.4 x = p [2]. X * (1-T) + P [3]. X * t y = p [2]. Y * (1-T) + P [3]. Y * T Usage (1,2) and (4, -2) coordinates (x, y) = (2.2, 0.4)

Comments