# [✓] Create a constrained locator inside a polygon?

GROUPS:
 Dear Community,I have a closed polygon, and I would like to place a locator into it, so it remains constrained to the interior of the polygon, i.e. it never leaves the polygon when I drag it. How could I do it? My polygon is attached.Tx for the kind help in advance, Andras Attachments:
Answer
4 months ago
3 Replies
 This seems to work: DynamicModule[{pt = {.5, 10^7}}, Graphics[ {LightBlue, Polygon[pts], Locator[Dynamic[pt, (pt = RegionNearest[Polygon[pts], #]) &]]} , Axes -> True, AspectRatio -> 1]] 
Answer
4 months ago
 Dear Gianluca thank you so much, works indeed, yet I get a continuous flow of warnings upon moving the locator to the boundary:  LinearSolve::luc: Result for LinearSolve of badly conditioned matrix {{3.71649*10^13,3.71649*10^13}, {3.71649*10^13,3.71649*10^13}} may contain significant numerical errors. etc. How could I overcome this?Tx in advance, best regards Andras
Answer
4 months ago
 Now its OK, I've scaled down the polygon by 1.0E6, and now its fine. Tx once again Andras
Answer
4 months ago