Skip to content Skip to sidebar Skip to footer

How Do I Make A Function To Draw Arcs Inside A Matrix?

I need to make a function/method that draws arcs inside a matrix. I would use 1s as points that shape the arc and 0s as empty spots. So the function would produce something like th

Solution 1:

Hint:

A circular arc is the boundary of a domain of equation

(X - Xc)² + (Y - Yc)² ≤ R².

A starting point can be

(Xc + R, Yc).

Now from a known point, you can perform contour following, i.e. repeatedly find the next 8-neighbor that verifies the inequation.

This gives you a global idea. Handling the start and end point is a little tricky. And optimizations are possible by splitting the work in 8 octants. But this is a longer story.

Post a Comment for "How Do I Make A Function To Draw Arcs Inside A Matrix?"