FORUMS: list search recent posts

# Counteracting parent's rotation

FAQ   •   VIEW ALL
 Counteracting parent's rotation on May 22, 2013 at 9:05:17 pm

I'm trying to keep a text layer always straight and horizontal, no matter how the parent rotates.

Doing a simple negative rotation of the parent doesn't work. In this example, the text layer is a sub-sub-sub-child of a chain of parents. And those parents each have a wiggle applied.

How would I keep this 2d text layer always level?

 Re: Counteracting parent's rotationon May 22, 2013 at 9:41:59 pm

There are a couple of ways to do it. This is one:

v = toWorldVec([1,0,0]);

Dan

 Re: Counteracting parent's rotationon May 22, 2013 at 10:35:53 pm

It doesn't look like it's countacting the first parent's rotation. When I parent the text layer initially, it gains a rotation of 18° (base on the parent).

Then adding the expression makes it match up with it's first parent 18° off. It's not staying horizontal.

I subtracted 18 at the end of the expression to fix it. But that's more of a band-aid than a fix.

`-radiansToDegrees(Math.atan2(v[1],v[0])) - 18`

 Re: Counteracting parent's rotationon May 22, 2013 at 11:03:32 pm

Ah yes--sorry, that won't work for this situation.

Try this one:

L = thisLayer;
r = 0;
while(L.hasParent){
r += L.parent.rotation;
L = L.parent;
}
-r

Dan

 Re: Counteracting parent's rotationon May 23, 2013 at 4:42:53 pm

this got me wondering about an expression for the rotation on the orientation for a 3d layer. when he asked about keeping the subsubsub layer level, I was thinking of an orbiting type layer and THEN noticed they were all 2D. So I'm wondering Dan, what would you do for a layer parented to a layer's orientation in 3D space to keep it facing the camera all the time but with an expression? I've wondered this in the past because when the objects move past the camera, I'd rather have them facing the direction they're moving and not at the camera anymore.

So basically layers orbiting one layer in 3d space using the orientation or even just one of the rotation parameters ALL facing the camera.

Now that would be cool :)

Jason Jantzen
vimeo.com/jasonj

 Re: Counteracting parent's rotationon Jul 23, 2014 at 9:41:17 am

Counteracting parent's orientation/rotation in 3D is what I'm looking for. Can everyone help me continue on this problem?

 Re: Counteracting parent's rotationon Jul 23, 2014 at 9:53:07 pm

I'm not sure if this is what you're after, but try this Orientation expression:

u = fromWorldVec([1,0,0]);
v = fromWorldVec([0,1,0]);
w = fromWorldVec([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;
}

Dan

 Re: Counteracting parent's rotationon Jul 24, 2014 at 6:52:19 am

Oh my god Dan! You saved me on this! It worked like magic! Thank you very much! I am always your fan!