自由な点オブジェクトを、PointIn[ <多角形> ]と同じ挙動にする、あるいはその逆の挙動にする
自由な点オブジェクトPを作成する。多角形オブジェクトpoly1を作成する。
点Pの可動領域を、poly1の内部(および辺上)に限定するには、点PのOn Update ハンドラに、以下のスクリプトを記述すれば良い。
If[P!=ClosestPointRegion[poly1,P],SetValue[P,ClosestPointRegion[poly1,P]]]
点Pの可動領域を、poly1の外部(および辺上)に限定するには、点PのOn Update ハンドラに、以下のスクリプトを記述すれば良い。
If[P==ClosestPointRegion[poly1, P],SetValue[P,ClosestPoint[PolyLine[{Vertex[poly1],Element[{Vertex[poly1]}, 1]}], P]]]