# How to check if point is in elliptical sector without float-point arithmetic?

How can I check whether point lies in elliptical sector without float-point arithmetic if I know a and b from the ellipse equation, start and end angles of the sector and x, y coordinates of the point.

• What is an "elliptical sector"? Are $a,b$ and the $x,y$ coordinates given in "float-point"? Sep 25, 2018 at 11:19
• Elliptical sector is a part of ellipse, it is determined by start and end angles. a, b and points' coordinates given as integers. Sep 25, 2018 at 11:28
• Okay. How are the angles given? Integers also? Slopes of lines from the origin? Can you give an example of what you are given? Sep 25, 2018 at 11:41
• Yeah, actually I just have a bitmap and ellipse on it. I iterate all border points of that ellipse and want to determine whether point belogs to this sector or not. For example, angles could be 0 and 45. Sep 25, 2018 at 11:48
• Getting closer. Angle is integer degrees. Okay, I guess ellipse is $(x/a)^2+(y/b)^2 = 1.$ Should be enough now. Sep 25, 2018 at 11:59

The question is to check if the inequalities $$(x/a)^2 + (y/b)^2 \le 1, \tag{1}$$ $$\tan(t_1) \le y/x \le \tan(t_2). \tag{2}$$ hold for the integers $$\, x, y \,$$ where $$\, a,b>0 \,$$ are positive integers and $$\,t_1, t_2\,$$ are angles in degrees (or other units). We suppose we have available sine/cosine tables $$\, S(t) = \sin(t)\, r, \quad C(t) = \cos(t)\, r \,$$ where $$\, r>0 \,$$ is an integer radius of a circle. The first inequality is equivalent to $$b^2 x^2 + a^2 y^2 \le a^2b^2 \tag{3}$$ while the second is equivalent to $$S(t_1)x \le C(t_1)y, \quad C(t_2)y \le S(t_2)x \tag{4}$$ but we have to be careful if $$\, x<0, y<0 \,$$ or $$\,C(t_1)<0,\, C(t_2)<0 \,$$ and special case code to deal with that is probably the best idea.