A Circle and a Square

  • + 1 comment

    Checking if the points lies inside a square can be done without any floating point operations. Two hints (References almost contain the solution to this problem. Do not open them if you still want to figure your own way out just by using the hints) :

    • You can calculate the other veticies of the squre using the two diagonal points given using some maniputaion of vectors. The only factor of division by 2 can be taken to the other side of the inequalities while comparison, to avoid division. Reference
    • The actual condition for checking if point is inside the squre can be either done by the method of comparing the sum of areas or even better the dot product of edges of squre and the vector from vertex to point.Reference