Skip to main content
Inspiring
Jun 28, 2022 11:10 AM UTC
Answered

Calculating auto tangent for 3 random points

Hi there,

How could we calculate auto tangent for second point amoung 3 random points in space.

This topic is closed to new replies. Start a new post to keep the conversation going.
Mahesh ShettyCorrect answer
Participant
Jun 29, 2022 6:15 AM UTC

In Rotobazier, intangents and out tangets are parallel to the line formed between previous point and next point and lengths of those tangets are 1/3 (or close to ) of length between current point and previous point ( for in tangent) , 1/3 of length between current point and next point (for out tangent  ).

Same is illustrated  with expression below.

 

p1=fromComp(thisComp.layer("1").transform.position);
p2=fromComp(thisComp.layer("2").transform.position);
p3=fromComp(thisComp.layer("3").transform.position);
// 3 Nulls to follow for position;


intan2=((p1-p3)/length(p1,p3)) * ( length(p2,p1)/3);
outtan2=((p3-p1)/length(p1,p3)) * ( length(p2,p3)/3);
// number 3 at denometer can be varied to adjust curve (>2 is better)

//((p1-p3)/length(p1,p3))   gives a tangent of unit length in required intan direction.

//((p3-p1)/length(p1,p3))    gives a tangent of unit length in required outtan direction.

 

pts=[p1,p2,p3];
intan=[[0,0],intan2,[0,0]];
outtan=[[0,0],outtan2,[0,0]];

createPath(points = pts, inTangents = intan, outTangents = outtan, isClosed = false)

 

 

4 replies

Mahesh ShettyCorrect answer
Participant
Jun 29, 2022 6:15 AM UTC

In Rotobazier, intangents and out tangets are parallel to the line formed between previous point and next point and lengths of those tangets are 1/3 (or close to ) of length between current point and previous point ( for in tangent) , 1/3 of length between current point and next point (for out tangent  ).

Same is illustrated  with expression below.

 

p1=fromComp(thisComp.layer("1").transform.position);
p2=fromComp(thisComp.layer("2").transform.position);
p3=fromComp(thisComp.layer("3").transform.position);
// 3 Nulls to follow for position;


intan2=((p1-p3)/length(p1,p3)) * ( length(p2,p1)/3);
outtan2=((p3-p1)/length(p1,p3)) * ( length(p2,p3)/3);
// number 3 at denometer can be varied to adjust curve (>2 is better)

//((p1-p3)/length(p1,p3))   gives a tangent of unit length in required intan direction.

//((p3-p1)/length(p1,p3))    gives a tangent of unit length in required outtan direction.

 

pts=[p1,p2,p3];
intan=[[0,0],intan2,[0,0]];
outtan=[[0,0],outtan2,[0,0]];

createPath(points = pts, inTangents = intan, outTangents = outtan, isClosed = false)

 

 

Translate
Dan Ebberts
Community Expert
Community Expert
Jun 28, 2022 2:40 PM UTC

I think the formula for the auto bezier out tangent is (next point - previous point)/6 and the in tangent is the inverse of that. So building your 3-point path with an expression would look like this (although the tangents for the first and third points don't match what you have in your illustration):

p1 = [561,589];
p2 = [1105,256];
p3 = [1188,787];

p = [fromComp(p1),fromComp(p2),fromComp(p3)];
iT = [[0,0],(p1-p3)/6,(p2-p3)/6];
oT = [(p2-p1)/6,(p3-p1)/6,[0,0]];
createPath(p,iT,oT,false);
Translate
Mylenium
Legend
Jun 28, 2022 1:46 PM UTC

What "auto-tangent"? There is no specific formula for that and the criteria for the tangents are completely arbitrary and up to whatever you deem suitable. Otherwise you simply can mimic a standard B-Spline behavior by hard-coding a few values in the Bèzier formula so it effectively is only a bicubic spline like zeroing out the third component.

 

Mylenium

Translate
Joost van der Hoeven
Community Expert
Community Expert
Jun 28, 2022 11:59 AM UTC

Not a math specialist myself, but this might help?
http://www.motionscript.com/expressions-lab-ae65/bezier.html

Translate