A Circle and a Square

  • + 0 comments

    Alternatively, for the square part, one can rotate the coordinate system so as to have the square aligned with the horizontal and vertical directions. Then it is enough to check each coordinate separately i.e. given a point (x, y) whether x is between x1 and x3 (all values after rotation), and similarly for y. In this case we operate with floating point numbers, and need to be careful with precision errors (use small epsilon when comparing numbers).