Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions toWorldVec – global orientation fails when above 90 degrees

  • toWorldVec – global orientation fails when above 90 degrees

    Posted by Simon Bjork on January 3, 2021 at 12:36 pm

    I’m having some trouble with extracting the global orientation values using the toWorldVec method.

    It all seems to work well as long as the rotation values are within -90 and 90, but outside of that it fails. Example:

    – Create a new camera and animate the Y rotation from 0 – 150 degrees.

    – Create a text layer and apply the following expression to the sourceText property (Dan Ebberts):

    C = thisComp.layer("Camera 1");
    u = normalize(C.toWorldVec([1,0,0]));
    v = normalize(C.toWorldVec([0,1,0]));
    w = normalize(C.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 = Math.atan2(u[1],v[1]);
    c = 0;
    }
    s1 = "3x3 Matrix: \n" + u + "\n" + v + "\n" + w
    s2 = "Rotations:\n" + radiansToDegrees(a) + " " + radiansToDegrees(b) + " " + radiansToDegrees(c)

    s1 + "\n\n\n" + s2

    <div>As soon as the rotation gets above 90, everything breaks. The X rotation and Z rotations change from 0 to -180 and 180 and the Y rotation starts to move in the opposite direction.
    </div><div>

    Any suggestions how to fix this? If possible I’d like to edit the matrix (toWorldVec) as I’m not using this particular matrix > euler conversion. But I’m open to any suggestions.

    Thanks,

    Simon

    </div>

    Simon Bjork replied 5 years, 8 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy