**Code 2.**

IF ((int (2*x*/√3) mod 2 = 0) AND (int (*y*/1.5) mod 2) = 0) OR (int (2*x*/√3) mod 2 = 1) AND (int (*y*/1.5) mod 2) = 1)) THEN "CB Rectangle is involved" ELSE "AB Rectangle is involved"

where:


Now, the involved rectangle is specified and the third step follows. Since we have two types of rectangles AB and CB, and they are symmetric, we will discuss only one of them known as type AB rectangles.

In rectangle AB, a point (*<sup>x</sup>*, *y*) will belong to either part A or part B. To decide which one is involved, we consider Line 1 (L1) and Line 2 (L2) in Figure 8b, where they divide the rectangle into parts A and B. If the point is between L1 and L2, then part A is involved. Otherwise, it is in part B. However, L1 and L2 are considered to be within the area A in cases when the point is on the lines. Equations (3) and (4) of a straight line are used for Line 1 and Line 2, respectively.

$$m \cdot x + r\_1 - y = 0,\tag{3}$$

$$m \cdot x + r\_2 - y = 0,\tag{4}$$

where:


This step is started by substituting the point (*<sup>x</sup>*, *y*) in Equations (3) and (4). Then, it is determined that part A is involved if the left side of Equation (3) is not greater than 0 and the left side of Equation (4) is not less than 0. Otherwise, part B is involved. Code 3 is used to clarify this step.
