I am quite successful with the circle using this approach Mexa linked me. It accounts for most problems, which raised with my previous approaches when detecting circles.
For the line, the angle approach is a little problematic, because everything with just a small nose (shaped like a 1) or a little backtracking involved would show huge angle discrepancies, while still being clearly a line for the most part.
Currently thinking about drawing a linear slope through start and finish and then compare the distance of each point to the line; however I might need a better method than just taking the first and last point... maybe average all points to get a center and average all angles to get an angle... then take min/max values for x and y to limit the line... hmmm
€Beier... for some reason my enrichments for points look exactly like yours :D
Will test yours, but I will try to finish mine ;)
€ Beier, your stuff doesn't seem to work properly. When i draw a horizontal or vertical line, I get sometimes a line, sometimes a circle, sometimes even a division by zero. Also always a Probably not a match message.
Basically, i have a set of points, which read out the user's mouse input (think of a picture drawn in Pictionary). I would like to detect, if these points represent one of certain shapes. Nothing special, a differentiation between circle, straight line and curved line should suffice.
It should cut you some slack, of course, since you cannot draw a perfect circle with the mouse, and it should approximate the closest exact shape.
Attached some pictures to clarify this.
What I have tried so far is checking the angle of the points to each other to check for a line (which malfunctions, if you backtrack on the line just a little), checking the distance from start to end for a circle (which malfunctions, if you paint just a little too far, also it doesn't really care about the shape this way)
Thanks for your help; I think I got it to work like I need it.
I am quite successful with the circle using this approach Mexa linked me. It accounts for most problems, which raised with my previous approaches when detecting circles.
For the line, the angle approach is a little problematic, because everything with just a small nose (shaped like a 1) or a little backtracking involved would show huge angle discrepancies, while still being clearly a line for the most part.
Currently thinking about drawing a linear slope through start and finish and then compare the distance of each point to the line; however I might need a better method than just taking the first and last point... maybe average all points to get a center and average all angles to get an angle... then take min/max values for x and y to limit the line... hmmm
€Beier... for some reason my enrichments for points look exactly like yours :D
Will test yours, but I will try to finish mine ;)
€ Beier, your stuff doesn't seem to work properly. When i draw a horizontal or vertical line, I get sometimes a line, sometimes a circle, sometimes even a division by zero. Also always a Probably not a match message.
Hey.
Basically, i have a set of points, which read out the user's mouse input (think of a picture drawn in Pictionary). I would like to detect, if these points represent one of certain shapes. Nothing special, a differentiation between circle, straight line and curved line should suffice.
It should cut you some slack, of course, since you cannot draw a perfect circle with the mouse, and it should approximate the closest exact shape.
Attached some pictures to clarify this.
What I have tried so far is checking the angle of the points to each other to check for a line (which malfunctions, if you backtrack on the line just a little), checking the distance from start to end for a circle (which malfunctions, if you paint just a little too far, also it doesn't really care about the shape this way)