Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Some trig help needed

  • Some trig help needed

    Posted by Nick Hill on July 12, 2009 at 12:13 am

    It’s 1am and I can’t think straight any more… I’ve got a graphic of a tandem and a trailer, which I’m animating using nulls so that the wheels always touch the ground. I got the tandem wheels working, but am having trouble with the trailer… basically I think this could be summarised as “from the diagram below, what’s the formula to make B always touch the line between C and D?” The positions of A, C and D are known, as is the length ab. (A is the “hinge” connecting the trailer to the bike, C is the bike’s rear wheel contact point, B is the trailer wheel’s contact point defined by a point control that doesn’t move, and D is a null that can pretty much go wherever it wants to.)

    At this point I’m just going round in circles, any help would be appreciated!

    Nick Hill replied 17 years, 1 month ago 1 Member · 1 Reply
  • 1 Reply
  • Nick Hill

    July 12, 2009 at 4:52 pm

    I *think* I’ve done it (well, it’s good enough, at least). Expression for the rotation:


    wo = effect("WheelOffset")("Angle"); // arbitrary angle control for fine tuning
    Cxy = thisComp.layer("Tandem").effect("RearWheelContactPoint")("Point"); // C in the diagram
    Axy = transform.position; // hinge point: A
    Bxy = effect("WheelPoint")("Point"); // Rear wheel contact point: B
    Dxy = thisComp.layer("TrailerWheelGuide").transform.position; // trailer wheel guide: D

    c = length(Axy, Bxy);

    theta = Math.atan2(Dxy[1]-Cxy[1], Dxy[0]-Cxy[0]);

    sintheta = Math.sin(theta);
    costheta = Math.cos(theta);
    xs = Axy[0] - Cxy[0];
    ys = Axy[1] - Cxy[1];

    alpha = Math.asin(((sintheta * xs) - (costheta * ys)) / c) + theta;

    radiansToDegrees( alpha ) + wo;

    Now to figure out why the guy’s shins are coming out of his shoes whenever I move the bike around….

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