Mailing List AE-List@media-motion.tv ? Message #42104
From: Dan Ebberts <debberts@comcast.net>
Subject: Re: [AE] Constrain to circle perimeter.
Date: Mon, 13 Feb 2012 14:48:09 -0800
To: After Effects Mail List <AE-List@media-motion.tv>
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
 
From: Nick Guth
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
 
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to ListMaster