Skip to main content
Inspiring
June 28, 2022
Answered

Calculating auto tangent for 3 random points

  • June 28, 2022
  • 4 replies
  • 949 views

Hi there,

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

This topic has been closed for replies.
Correct answer Mahesh Shetty

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
June 29, 2022

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)

 

 

Dan Ebberts
Community Expert
Community Expert
June 28, 2022

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);
Mylenium
Legend
June 28, 2022

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

Joost van der Hoeven
Community Expert
Community Expert
June 28, 2022

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