Drawing arcs

I have been trying to draw arcs on LCD however no luck :). The adagfx library uses the common circle algorithm which you can not alter for 3 point arcs. So any ideas ? I searched the web but trigonometric approach is too slow to use and could not find a fast algorithm yet.

Help would be highly appreciated :slight_smile:

The adagfx library uses the common circle algorithm which you can not alter

Why? Don't you have a text editor?

Lol :)

Thats a good idea let me install text editor...

Getting back to the question, people who knows the algoritm would understand what i mean...

What he is saying is that your assertion that you cannot alter the library is false. If you have a text editor ( like wordpad or anything) on your computer then you have all you need to alter that code.

I was thinking that this sentence does not mean "I do not have a text editor", anyways it is the second fish in the bowl so let me try to be more specific.

"The adagfx library uses the common circle algorithm which you can not alter for 3 point arcs. "

Sure you can alter but the circle function in the library is NOT SUITABLE.

Looks like my english is not good enough to describe the issue.

The issue is if we had an algorithm that draws a circle based on angle you could be able to alter that (with a text editor :P) to fit a circular arc. However it is not angular, it is kind of modular.

If your answer will be modular is also angular, do not bother, please answer only if you understand what i mean and willing to help instead of talking nonsense.

Thank you...

Perhaps if you defined the problem in a sensible way, you would get helpful responses.

For example, if you are looking for an algorithm to first fit and then draw an arc through three 2D points, (e.g. starting with P1, passing through P2 and ending on P3) then it is likely that there is no fast solution. There are lots of special cases that would have to be checked.

However it is not angular, it is kind of modular.

I discovered that algorithm a couple of months ago. I didn't go deep into it, but -i think- I made myself an idea of how it works.

What do you mean by modular vs angular?

Regards

Hello vffgaston

I mean it splits a circle to 8 parts and draws 8 parts separately with different modules.

So if you want it to draw arcs, it is nearly impossible without putting a lot of logical functions, in the end most probably you would end up with a slower algorithm than the triangular one.

Anyways, I was expecting some god mode experts in arduino to step in and enlighten me :)

Did not happen :) I will resolve it somehow but thanks for your help...

some go mode experts in arduino

?

@jremington, “go mode”

@Monalith, I briefly reviewed “circle through 3 points” and the Midpoint Circle Algorithm (aka Bresenham’s algorithm). While you can get the center and radius from the former, drawing just the arc with the latter is a little messy. As you noted, the octant approach makes it a little tricky.

You could change the approach to plotting just one pixel at each step, instead of 8, walking all the way around the circle instead of just one octant. This requires changing the stepping from X to Y at 4 of the octant boundaries (the odd 45s). The increment may change sign at any of the octant boundaries (the 90s).

That is, if octant boundary 0 is the East direction (positive x direction), then CCW:

Octant Step Inc
0 Y+ X-
1 X- Y+
2 X- Y-
3 Y- X-
4 Y- X+
5 X+ Y-
6 X+ Y+
7 Y+ X+

It should be obvious to the most casual observer that only a Small Matter Of Programming is required. This is left as an exercise for the reader. :smiley:

As others have noted, by the time you calculate the center and radius, then plot each pixel, you could have probably drawn the line segments. Not to mention the amount of thinking and code…

Cheers,

@jremington, "go mode"

Thanks, but didn't help.

The "circle through 3 points" algorithm presented does not check for any degenerate cases, and the most straightforward method requires one to invert a 3x3 matrix. Not the ideal situation for an Arduino.

If anything, you could do it the old fashion way by using sin and cos. It's slow but it always works.