I want to know the most efficient way to check if a given point (an eye coordinate) is within a specific region (in this case a circle).
win = visual.Window([600,600], allowGUI=False)
coordinate = [50,70] #example x and y coordinates
shape = visual.Circle(win, radius=120, units='pix') #shape to check if coordinates are within it
if coordinate in shape:
>>TypeError: argument of type 'Circle' is not iterable
ShapeStim classes have a
.contains() method, as per the API:
So your code could simply be:
if shape.contains(coordinate): print 'inside' else: print 'outside'
Using this method has the advantage that it is a general solution (taking into account the shape of the stimulus vertices) and is not just a check on the pythagorean distance from the stimulus centre (which is a special case for circles only).