Return-Path: Received: from qmta03.emeryville.ca.mail.comcast.net ([76.96.30.32] verified) by media-motion.tv (CommuniGate Pro SMTP 4.2.10) with ESMTP id 4849432 for ae-list@media-motion.tv; Mon, 17 Sep 2012 20:11:34 +0200 Received: from omta15.emeryville.ca.mail.comcast.net ([76.96.30.71]) by qmta03.emeryville.ca.mail.comcast.net with comcast id 0Cos1k0071Y3wxoA3JCzqK; Mon, 17 Sep 2012 18:12:59 +0000 Received: from HPZ200 ([76.20.32.7]) by omta15.emeryville.ca.mail.comcast.net with comcast id 0JCy1k00C09DSM08bJCysG; Mon, 17 Sep 2012 18:12:58 +0000 Message-ID: <98A6A4CB1CEE4F8D98B2BE81F040246F@HPZ200> From: "Dan Ebberts" To: "After Effects Mail List" References: In-Reply-To: Subject: Re: [AE] Layer Space transform onto parented layers Date: Mon, 17 Sep 2012 11:12:58 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0033_01CD94C5.64C8C5C0" X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 15.4.3555.308 X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3555.308 This is a multi-part message in MIME format. ------=_NextPart_000_0033_01CD94C5.64C8C5C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This should give you the position: L =3D thisComp.layer("parented null"); L.toWorld(L.anchorPoint); And this should give you the orientation: L =3D thisComp.layer("parented null"); u =3D L.toWorldVec([1,0,0]); v =3D L.toWorldVec([0,1,0]);=20 w =3D normalize(L.toWorldVec([0,0,1]));=20 sinb =3D clamp(w[0],-1,1); b =3D Math.asin(sinb); cosb =3D Math.cos(b); if (Math.abs(cosb) > .0005){ c =3D -Math.atan2(v[0],u[0]); a =3D -Math.atan2(w[1],w[2]); }else{ a =3D (sinb < 0 ? -1 : 1)*Math.atan2(u[1],v[1]); c =3D 0; } [radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)] Dan From: Byron Nash=20 Sent: Monday, September 17, 2012 10:20 AM To: After Effects Mail List=20 Subject: Re: [AE] Layer Space transform onto parented layers How about the other direction? I have a layer that is parented inside a = heirarchy. I need to match another layer to it that is unparented. Most = of the motion is from the parent layers rotation. Also, I have moved the = anchorpoints around so they are not in the center. I am trying = different combinations of toWorld and fromWorld and can't seem to get it = working. I need another one on the rotation to get it oriented = correctly, would that go on Orientation or the individual axes? On Wed, Sep 5, 2012 at 6:06 PM, Darby Edelen wrote: This line: parent.fromWorld(p); Should work no matter how deeply parented the null is. The reason = being that it will take a world position (p) and transform it into the = local/layer space of the current layer's parent. This is exactly how a = child's position is defined (i.e. in the parent's local/layer space). The part that is really important is the parent.fromWorld(). You could = put any world coordinate in there and it should work. On Sep 5, 2012 11:19 PM, "Byron Nash" wrote: Thanks for the expression. I haven't had a chance to test it yet. I = did not think of stacking the toWorld and fromWorld. What if the = parented null is several parent layers deep?=20 On Wed, Sep 5, 2012 at 12:39 PM, Darby Edelen = wrote: In order to transform the parented null to the unparented null = you'll need to use an expression in this form; applied to the parented = null's position: l =3D thisComp.layer("unparented null"); p =3D l.toWorld(l.anchorPoint); parent.fromWorld(p); I can't confirm this is correct at the moment, but it should at = least be close. On Sep 5, 2012 5:37 PM, "Byron Nash" wrote: I need to "constrain" one null to another with Layer Space = transforms. The null that I am matching FROM is not parented at all. The = one I am wanting to add the expression TO is parented several levels = deep. I have tried various combinations of toComp, fromComp, toWorld, = fromWorld, etc... What is the proper way to apply a comp position value = to a layer that is inheriting many levels of offsets?=20 Thanks! ------=_NextPart_000_0033_01CD94C5.64C8C5C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
This should give you the position:
 
L =3D thisComp.layer("parented null");
L.toWorld(L.anchorPoint);
 
And this should give you the orientation:
 
L =3D thisComp.layer("parented null");
u =3D L.toWorldVec([1,0,0]);
v =3D L.toWorldVec([0,1,0]);
w =3D normalize(L.toWorldVec([0,0,1]));
 
sinb =3D clamp(w[0],-1,1);
b =3D Math.asin(sinb);
cosb =3D Math.cos(b);
if (Math.abs(cosb) > .0005){
  c =3D -Math.atan2(v[0],u[0]);
  a =3D -Math.atan2(w[1],w[2]);
}else{
  a =3D (sinb < 0  ?  -1 : = 1)*Math.atan2(u[1],v[1]);
  c =3D 0;
}
[radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]
 
 
Dan
 
 
From: Byron Nash
Sent: Monday, September 17, 2012 10:20 AM
Subject: Re: [AE] Layer Space transform onto parented=20 layers
 
How=20 about the other direction? I have a layer that is parented inside a = heirarchy. I=20 need to match another layer to it that is unparented. Most of the motion = is from=20 the parent layers rotation. Also, I have moved the anchorpoints around = so they=20 are not in the center.  I am trying different combinations of = toWorld and=20 fromWorld and can't seem to get it working. I need another one on the = rotation=20 to get it oriented correctly, would that go on Orientation or the = individual=20 axes?

On Wed, Sep 5, 2012 at 6:06 PM, Darby Edelen = <dedelen@gmail.com> wrote:

This line:

parent.fromWorld(p);

Should work no matter how deeply parented the null is. The reason = being=20 that it will take a world position (p) and transform it into the = local/layer=20 space of the current layer's parent. This is exactly how a child's = position is=20 defined (i.e. in the parent's local/layer space).

The part that is really important is the parent.fromWorld(). You = could put=20 any world coordinate in there and it should work.

On Sep 5, 2012 11:19 PM, "Byron Nash" <byronnash@gmail.com>=20 wrote:
Thanks for the expression. I haven't had a chance = to test=20 it yet. I did not think of stacking the toWorld and fromWorld. What = if the=20 parented null is several parent layers deep?

On Wed, Sep 5, 2012 at 12:39 PM, Darby = Edelen <dedelen@gmail.com> wrote:

In order to transform the parented null to the unparented null = you'll=20 need to use an expression in this form; applied to the parented = null's=20 position:

l =3D thisComp.layer("unparented null");
p =3D=20 l.toWorld(l.anchorPoint);
parent.fromWorld(p);

I can't confirm this is correct at the moment, but it should at = least=20 be close.

On Sep 5, 2012 5:37 PM, "Byron Nash" = <byronnash@gmail.com> wrote:
I need to "constrain" one null to another with = Layer=20 Space transforms. The null that I am matching FROM is not = parented at=20 all. The one I am wanting to add the expression TO is parented = several=20 levels deep. I have tried various combinations of toComp, = fromComp,=20 toWorld, fromWorld, etc... What is the proper way to apply a = comp=20 position value to a layer that is inheriting many levels of = offsets?=20
 
=
Thanks!

<= /BLOCKQUOTE>
 
------=_NextPart_000_0033_01CD94C5.64C8C5C0--