Automatch matchmoved layer motionblur to source footage

Moderators: Disciple, zlovatt

Post Reply
Redsandro
Posts: 108
Joined: June 25th, 2008, 4:55 pm

October 25th, 2008, 2:40 pm

[update]
Done, go here.
[/update]


I know it's supposed to be simple and I am ashamed I didn't figure it out yet :oops:

But what's the trick again to convert two 2d points to a rotation value? I want to convert a directional vector to a rotation value, and here's what I've got:

Code: Select all

// Get positions
Layer1 = thisComp.layer("PosLayer")
Pos1 = Layer1.toWorld(Layer1.anchorPoint);
Pos2 = Layer1.toWorld(Layer1.anchorPoint.valueAtTime(framesToTime(timeToFrames()-1)));
delta = Pos2 - Pos1;
radiansToDegrees(Math.atan2(delta[1],delta[0]));
But it's remaining at 0.. I am doing something wrong.

-edit-
Title changed to match content of this topic.
Last edited by Redsandro on October 26th, 2008, 7:23 am, edited 2 times in total.
avi + m2t -> Vdub + DGIndex -> AE CS3 -> x264 -> Hell On Earth :mrgreen:
Dan Ebberts
Posts: 319
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

October 26th, 2008, 12:07 am

Try this:

Layer1 = thisComp.layer("PosLayer")
Pos1 = Layer1.toWorld(Layer1.anchorPoint);
Pos2 = Layer1.toWorld(Layer1.anchorPoint,framesToTime(timeToFrames()-1));
delta = Pos2 - Pos1;
radiansToDegrees(Math.atan2(delta[1],delta[0]));

Dan
Redsandro
Posts: 108
Joined: June 25th, 2008, 4:55 pm

October 26th, 2008, 6:59 am

Great!
I didn't know .toWorld takes time as a second parameter. Thanks!
avi + m2t -> Vdub + DGIndex -> AE CS3 -> x264 -> Hell On Earth :mrgreen:
Redsandro
Posts: 108
Joined: June 25th, 2008, 4:55 pm

October 26th, 2008, 7:18 am

Made an expression to automatically match matchmoved layers' motionblur to the source footage's motion blur.
Simple idea but pretty awesome result imo. :)

Code: Select all

// Redsandro 2008-10-26
// effect("Directional Blur")("Direction")

// Position Source Layer (not parented)
lay = thisComp.layer("Tr Main Avg 1")

// Math
pos1 = lay.toWorld(lay.anchorPoint);
pos2 = lay.toWorld(lay.anchorPoint,framesToTime(timeToFrames()-1));
delta = pos2 - pos1;
radiansToDegrees(Math.atan2(delta[1],delta[0]))-90;

Code: Select all

// Redsandro 2008-10-26
// effect("Directional Blur")("Blur Length")

// Position Source Layer (not parented)
lay = thisComp.layer("Tr Main Avg 1");

// Get positions
pos1 = lay.transform.position;
pos2 = lay.transform.position.valueAtTime(framesToTime(timeToFrames()-1));

// Calculate length
len = pos1 - pos2;
len = Math.sqrt(len[0]*len[0]+len[1]*len[1]);

// Convert to descent blur length
len/3; // Eyeball-change to match footage blur length
avi + m2t -> Vdub + DGIndex -> AE CS3 -> x264 -> Hell On Earth :mrgreen:
Redsandro
Posts: 108
Joined: June 25th, 2008, 4:55 pm

October 26th, 2008, 8:10 am

I borrowed this part though, it's in all rotation calculating expressions around:

Code: Select all

radiansToDegrees(Math.atan2(x,y))
But I was wondering how to write this in code:

tan^-1(something)

because the inverse tangent of the quotient is already in degrees. I always try to figure this out until I find the Math.atan2 used somewhere on the net and to be honest I don't really get what it does. I like to stick to degrees. And the inverse tangent is universal, right? Or are only European calculators working in degrees?
avi + m2t -> Vdub + DGIndex -> AE CS3 -> x264 -> Hell On Earth :mrgreen:
Dan Ebberts
Posts: 319
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

October 26th, 2008, 11:19 am

All the JavaScript trig functions work in radians. Math.atan() only takes one argument (the quotient of y/x) where Math.atan2() takes y and x separately. Also, I believe Math.atan2() can handle the case where x is 0.

Dan
Redsandro
Posts: 108
Joined: June 25th, 2008, 4:55 pm

October 27th, 2008, 7:12 am

Ah, that's why.

Actually I understand now that Math.atan(something) is similar to tan^-1(something).
Makes sense now :)
avi + m2t -> Vdub + DGIndex -> AE CS3 -> x264 -> Hell On Earth :mrgreen:
Post Reply