Activity › Forums › Adobe After Effects Expressions › position of a parented layer
-
position of a parented layer
Posted by Luke Halls on April 27, 2008 at 9:54 pmHi,
I’m sure i am missing something really simple but…
Is there a way of working out the position of an offset parented layer including rotation applied to the parent layer?
thanks
Luke
Luke Halls replied 18 years ago 3 Members · 4 Replies -
4 Replies
-
Darby Edelen
April 27, 2008 at 11:22 pm[Luke Halls] “Is there a way of working out the position of an offset parented layer including rotation applied to the parent layer? “
If I understand what you’re asking, you’ll need to use layer space transformations. Once you make a layer the child of a parent layer, the child’s layer transformations are in the parent’s layer space instead of world space… So what you need to do is transform the child’s transform values from the parent’s layer space to the world space:
v = transform.position; //'v' is the value we're transformingif(hasParent){ //If this layer has a parent...
l = parent; //The parent layer of this layer
l.toWorld(v); //Return the value 'v' in the layer space of layer 'l' transformed into world space
}
else v; //Otherwise return 'v'
The above code is specific to the position property. Other properties will require slightly different approaches.
Darby Edelen
Lead Designer
Left Coast Digital
Santa Cruz, CA -
Dan Ebberts
April 28, 2008 at 3:46 pmWorld position of child layer:
L = thisComp.layer(“child”);
L.toWorld(L.anchorPoint)World rotation of child layer:
L = thisComp.layer(“child”);
v = L.toWorldVec([1,0,0]);
radiansToDegrees(Math.atan2(v[1],v[0]))Dan
-
Dan Ebberts
April 28, 2008 at 4:04 pmOh yeah, I forgot scale:
L = thisComp.layer(“child”);
sx = L.scale[0]/100;
sy = L.scale[1]/100;while (true){
if( ! L.hasParent) break;
L = L.parent;
sx *= L.scale[0]/100;
sy *= L.scale[1]/100;
}
[sx,sy] * 100;Dan
Reply to this Discussion! Login or Sign Up