This should give you the position:
L = thisComp.layer("parented null");
L.toWorld(L.anchorPoint);
And this should give you the orientation:
L = thisComp.layer("parented null");
u = L.toWorldVec([1,0,0]);
v = L.toWorldVec([0,1,0]);
w = normalize(L.toWorldVec([0,0,1]));
sinb = clamp(w[0],-1,1);
b = Math.asin(sinb);
cosb = Math.cos(b);
if (Math.abs(cosb) > .0005){
c = -Math.atan2(v[0],u[0]);
a = -Math.atan2(w[1],w[2]);
}else{
a = (sinb < 0 ? -1 :
1)*Math.atan2(u[1],v[1]);
c = 0;
}
[radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]
Dan
Sent: Monday, September 17, 2012 10:20 AM
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
<dedelen@gmail.com> 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" <
byronnash@gmail.com>
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?
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
need to use an expression in this form; applied to the parented null's
position:
l = thisComp.layer("unparented null");
p =
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" <
byronnash@gmail.com> 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?
Thanks!