I am given the the coefficients for an ellipse in the form: $$Ax^2 + Bxy + Cy^2 + Dx + Ey + F=0.$$
I have a 2 dimensional array of point objects (in Python) called "pixels", and I need to give each point a "count" if they lie inside the ellipse.
I initially tried iterating through every point with a loop like:
for row in pixels:
for pixel in rows:
x=point.get(pixel)[0]
z=point.get(pixel)[1]
if a*(x)**2 + b*(x*z) + c*(z)**2 + d*(x) + e*(z) + f >0:
pixel.addpcount()
But this is taking way too long because I have several thousand ellipses I need to do this for. Is there a way I can efficiently do this?
(If this is not the right place to ask this question, I apologize.)
Edit: (I don't have enough reputation to comment). The Python is mostly irrelevant to my question at hand. I just want a better algorithm instead of iterating through every point.
In order to determine whether something is inside an ellipse, I am actually using this test https://math.stackexchange.com/questions/817130/how-to-determine-if-arbitrary-point-lies-inside-or-outside-a-conic.
The user Evil suggested using Axis Aligned Bounding Box. Does this mean finding the box which bounds an ellipse, and then testing only those points inside the box? That would seem a lot more efficient.
Greybeard, I am not sure what the Bresenham algorithm is, but I will take a look.