Hi everyone,
I use Adafruit_ILI9341 and want to draw ellipse to make an Easter egg to teach kids to be displayed on the LCD screen. I have looked at the libraries and there are only draw rect and circle. Anyone has any suggestions? Would appreciate any help.
Thank you.
Mai
How do I draw ellipse - Urgent
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- tkinsman
- Posts: 170
- Joined: Sun Sep 25, 2016 2:04 pm
Re: How do I draw ellipse - Urgent
Hah!
Some college students cannot get this.
Here's one solution, in Pseudo-code, and you can work out the particulars.
For all theta = 0 to 360 degrees
x = radius * cos( theta )
y = radius * sin( theta )
Now, you have values that go +/- 1.
You want the major axis of the ellipse to be bigger, so you multiply all the X values by the length of half the major axis (the semi-major axis).
Then you multiply all the Y values by the length of half the minor axis (the semi-minor axis).
This gives you an axially-aligned ellipse.
If you want the points rotated, you multiply each (x,y) pair through a rotation matrix. (They are all over the internet, but
basically they are [ cos( rotation ) sin( rotation ) ; -sin(rotation) cos( rotation ) ].
Then, add the center X and the center Y values, and you will have a set of values, which, when plotted, give you an ellipse.
It won't be perfectly egg shaped, but will be closer than a circle.
Cheers!
Some college students cannot get this.
Here's one solution, in Pseudo-code, and you can work out the particulars.
For all theta = 0 to 360 degrees
x = radius * cos( theta )
y = radius * sin( theta )
Now, you have values that go +/- 1.
You want the major axis of the ellipse to be bigger, so you multiply all the X values by the length of half the major axis (the semi-major axis).
Then you multiply all the Y values by the length of half the minor axis (the semi-minor axis).
This gives you an axially-aligned ellipse.
If you want the points rotated, you multiply each (x,y) pair through a rotation matrix. (They are all over the internet, but
basically they are [ cos( rotation ) sin( rotation ) ; -sin(rotation) cos( rotation ) ].
Then, add the center X and the center Y values, and you will have a set of values, which, when plotted, give you an ellipse.
It won't be perfectly egg shaped, but will be closer than a circle.
Cheers!
Please be positive and constructive with your questions and comments.