4 Replies Latest reply on Aug 4, 2017 5:12 AM by marco san

# offset corner pin with different x y offset values

Hello!

Suppose you have a keyframed corner pin effect. Is there a way to extend a pin point (example: top left corner point) with different offset values for X and Y using expressions?

I tried everything, but I can't get it to work: the extended point doesn't stick with the right proportion over the animation.

This expression is one of the many i applied without any success. It works only if offset X and Y values are equal (ex.

Any suggestion? Thanks.

// CALCULATE CENTER COORDINATES

TL = effect("Pin")(1);

TR = effect("Pin")(2);

DL= effect("Pin")(3);

DR = effect("Pin")(4);

var vertices_x = [];

var vertices_y = [];

var min_x = Math.min(TL[0],TR[0],DL[0],DR[0]);

var max_x = Math.max(TL[0],TR[0],DL[0],DR[0]);

var min_y = Math.min(TL[1],TR[1],DL[1],DR[1]);

var max_y = Math.max(TL[1],TR[1],DL[1],DR[1]);

var mid_x = (min_x + max_x) / 2;

var mid_y = (min_y + max_y) / 2;

center = [mid_x,mid_y];

// OFFSET

offset = [20,50];

// TOP LEFT VECTOR

vector = normalize(TL - center);

// CALCULATE NEW TOP LEFT

x = TL[0] + * vector[0] * offset[0];

y = TL[1] + * vector[1] * offset[1];

[x,y]

• ###### 1. Re: offset corner pin with different x y offset values

Doing this properly requires very heavy math. I do it for the "expressions instead of keyframes" option of MochaImport+.

It allows to move and even keyframe the corner pin corners freely and still make them move with the track automatically. But it requires some heavy preprocessing of the tracking data inside of MochaImport+ before the tracking data is generated.

See this tutorial to see it in action:

So if your corner pin comes from a mocha track, MochaImport+ is a good solution. Otherwise it will be very tricky.

Cheers,

Mathias

• ###### 2. Re: offset corner pin with different x y offset values

Well the reason your current code referenced above doesn't work is because you have "+ *" on lines 23 & 24, these should only be one or the other.

If it's a static amount of offset, why not just use this:

value + [20, 50]

?

• ###### 3. Re: offset corner pin with different x y offset values

If I understood it correctly, the offset should not be static in comp space, but adjust according to the movement of the corner pin. Like a static offset in the space defined by the corner pin surface.

• ###### 4. Re: offset corner pin with different x y offset values

Right Mathias Moehl That's what I need! The corner pin points change position over time, so the distance between them. The offset should change it's relative distance too.