Return-Path: Received: from qmta04.emeryville.ca.mail.comcast.net ([76.96.30.40] verified) by media-motion.tv (CommuniGate Pro SMTP 4.2.10) with ESMTP id 4625060 for ae-list@media-motion.tv; Mon, 13 Feb 2012 23:41:54 +0100 Received: from omta22.emeryville.ca.mail.comcast.net ([76.96.30.89]) by qmta04.emeryville.ca.mail.comcast.net with comcast id ZaaL1i0031vN32cA4ao7Gu; Mon, 13 Feb 2012 22:48:07 +0000 Received: from HPZ200 ([76.20.32.7]) by omta22.emeryville.ca.mail.comcast.net with comcast id Zao61i00Y09DSM08iao69M; Mon, 13 Feb 2012 22:48:07 +0000 Message-ID: From: "Dan Ebberts" To: "After Effects Mail List" References: In-Reply-To: Subject: Re: [AE] Constrain to circle perimeter. Date: Mon, 13 Feb 2012 14:48:09 -0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0093_01CCEA5E.80EF17C0" X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 15.4.3538.513 X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3538.513 This is a multi-part message in MIME format. ------=_NextPart_000_0093_01CCEA5E.80EF17C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable If you define the center and the radius, something like this should = work: c =3D [thisComp.width,thisComp.height]/2; // center r =3D 200; // radius d =3D length(value,c); if (d > r){ v =3D value - c; a =3D Math.atan2(v[1],v[0]); c + [Math.cos(a),Math.sin(a)]*r }else value Dan From: Nick Guth=20 Sent: Monday, February 13, 2012 2:38 PM To: After Effects Mail List=20 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! =20 I wish I could attach an example, but I can't get one to work! lol -- Nick ------=_NextPart_000_0093_01CCEA5E.80EF17C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
If you define the center and the radius, something like this should = work:
 
c =3D [thisComp.width,thisComp.height]/2; // center
r =3D 200; // radius
 
d =3D length(value,c);
if (d > r){
  v =3D value - c;
  a =3D 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=20 was hoping to enlist your guidance in a way to constrain a layers = position to=20 the perimeter of a circle. So I can freely move a little square inside = the=20 circle, but when trying to drag it outside the circle it would stop at = the edge.=20 My brain is fried from the long weekend I had and the math is slipping = me! =20
 
I wish I could attach an example, but I can't get one to work! = lol
 
--
Nick
------=_NextPart_000_0093_01CCEA5E.80EF17C0--