If you define the center and the radius, something like this should
work:
c = [thisComp.width,thisComp.height]/2; // center
r = 200; // radius
d = length(value,c);
if (d > r){
v = value - c;
a = Math.atan2(v[1],v[0]);
c + [Math.cos(a),Math.sin(a)]*r
}else
value
Dan
Sent: Monday, February 13, 2012 2:38 PM
Subject: [AE] Constrain to circle perimeter.
I
was hoping to enlist your guidance in a way to constrain a layers position to
the perimeter of a circle. So I can freely move a little square inside the
circle, but when trying to drag it outside the circle it would stop at the edge.
My brain is fried from the long weekend I had and the math is slipping me!
I wish I could attach an example, but I can't get one to work! lol
--
Nick