Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing an imperfect circle

Programatically drawing a perfect circle is not all that difficult. It's based on some very simple math, afterall. You input two parameters (a center and a radius) and output the circle.

But if you don't have tools to help you, drawing a circle freeform (as in holding a pen in your hand) is very difficult! If I wanted to simulate a person trying to draw a circle, is there any algorithm I could use that takes three parameters (a center, a radius, and a "wrongness factor") and uses the magnitude of the third value to create random imperfections in the circle, while still producing something that looks recognizably like a person trying to draw a circle?

like image 448
Mason Wheeler Avatar asked Nov 02 '22 21:11

Mason Wheeler


2 Answers

Plot the circle as a series of arcs, both "inwards" and "outwards", recalculating the correct center for each segment needed to keep the endpoint of the arc within a certain distance of the actual circumference.

like image 92
Ignacio Vazquez-Abrams Avatar answered Nov 16 '22 10:11

Ignacio Vazquez-Abrams


A circle drawn by free hand is random but still looks continuous. Adding noise to the radius might result in jumps which look unrealistic.

A slight modification can somewhat resolve this issue. Using a Markov matrix, divide the noise into N levels and have only tri-diagonal entries. This will result in randomness but yet it can only transit to prev/next levels only. Making it look continuous.

like image 28
Nishanth Avatar answered Nov 16 '22 10:11

Nishanth