enter image description here

the radius of the circles = 100 is long square sides = 400

whether it is necessary to check whether a point is in a circle: if so, then a point in a circle, if not, then a point in a square

My code example:

(print "Do you get a point in the square?") 

(cond (<= 400 x -400) && (<= 400 y -400) (print "Yes! Point in the square") (print "No! Point") (getpoint))

    1 answer 1

    You will need a function that checks whether the point lies with the specified coordinates inside the circle. I suggest using this implementation:

     (defun isPointInsideCircle (xy xc yc r) (< (+ (* (- x xc) (- x xc)) (* (- y yc) (- y yc))) (* rr))) 

    In addition, you need to check that the point lies inside the square. You can do this with this function:

     (defun isInsideRectangle (xy xc yc wh) (and (< (- x xc) w) (< (- y yc) h))) 

    In the end, it turns out that the point lies in the shaded part of the figure, if it does not go beyond the limits of the square and is not in any of the circles. We’ll cover all these conditions like this:

     (defun isInsideArea (xy) (let ((w 400) (h 400) (r 100) (xc1 100) (yc1 200) (xc2 300) (yc2 200)) (and (isInsideRectangle xy 0 0 wh) (not (isPointInsideCircle xy xc1 yc1 r)) (not (isPointInsideCircle xy xc2 yc2 r))))) 

    Example use of isInsideArea :

     (cond ((isInsideArea 100 399) "The point is inside the area") (t "The point is not inside the area"))