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 this matrix (only I would use 1400x700 matrix in reality):
000000000000000
000100000001000
000010000010000
000000111000000
000000000000000
I need to pass the following parameters to the function:
x:
the x coordinate
y:
the y coordinate
w:
the width
h:
the height
start:
the start angle, in degrees
extent:
the extent, in degrees
Now, I don't know the math on how to do it. Anyone could help me?
Hint:
A circular arc is the boundary of a domain of equation
A starting point can be
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.