0

I am drawing a path when a user drags his finger across screen. If, however, he does this too fast, I get too few points in path. Is there some way, I can increase the number of points in path after the user has drawn it? I need this because I am comparing each point of path1 to all points on path2 to see when these two paths are intersecting.

deeJ
  • 672
  • 11
  • 31

1 Answers1

1

If the user has already completed drawing a path, the best you can do is work with the points you have and guess at what goes between them. Two popular methods of guessing are to insert line segments between points, which gives a very jagged look, or you can use spline interpolation, which gives a very smooth look, but involves a more complicated calculation.

More info on spline interpolation: http://en.wikipedia.org/wiki/Spline_interpolation

Whether you use line segments or splines, you'll need to mathematically find the intersection by using the equations for the path1 segment/spline and the path2 segment/spline. You'll have two equations, two variables and so you should be able to solve the system to find the values for x and y that satisfy both equations, making that point the intersection.

http://en.wikipedia.org/wiki/Line-line_intersection

Jonathan M
  • 17,145
  • 9
  • 58
  • 91