java - Polygon "Fixing" Algorithm -
i bring maybe complex question love with. allow me go straight point:
i desire algorithm or logic in draw shape using mouse (for example square) , becomes perfect square, 4 sides in straight lines , regular. human-drawn square hardly perfect, wish after goes through "filter" of algorithm ,it becomes such.
a fine example of wish in game trine, wizard works similar principle: draw shape in screen , becomes closest shape, is, if draw similar square becomes perfect square box, if draw triangle becomes perfect triangular box. detects kind of shape , draws better version of it.
i want game, know goal of this.
please me figure out either algorithm or logic behind this, or @ least tell me name of kind of action (:
p.s. added simple image becomes more clear intend =)

if had implement task, store recognizable patterns, , try make match them.
take minx, maxx, miny, maxy values form user-drawn points, scale pattern. choose scaling aspect ratio pattern average of x , y aspect ratios.
the patterns can consist of number of straight lines. pattern matches if
- there no points outside of threshold
- there @ least 1 user-drawn point close each key points in pattern
if have pattern matched, have key points pattern (calculating center of pattern, , size/aspect ratio). can replace user-drawn points image - may totally different pattern used match (imagine circle).
Comments
Post a Comment