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.

- 672
- 11
- 31
-
1Are you truly drawing a line (which only needs two points), or a path (with multiple points)? – Jonathan M Apr 17 '12 at 17:20
-
@Jonathan corrected original post. Thanks. – deeJ Apr 17 '12 at 17:21
-
I found my answer here: http://stackoverflow.com/questions/3180531/android-path-to-array-read-the-points-on-a-path – deeJ Apr 18 '12 at 12:10
1 Answers
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.

- 17,145
- 9
- 58
- 91