## Adobe Support Community

• Calculating auto tangent for 3 random points

# Calculating auto tangent for 3 random points

Explorer ,
Jun 28, 2022 Jun 28, 2022

Copied

Hi there,

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

TOPICS
Expressions

Views

72

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more ## 2 Correct answers

Adobe Community Professional , Jun 28, 2022 Jun 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);``````

Likes

New Here , Jun 28, 2022 Jun 28, 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.posi

...

Likes 4 Replies 4
Jun 28, 2022 Jun 28, 2022

Copied

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Jun 28, 2022 Jun 28, 2022

Copied

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Jun 28, 2022 Jun 28, 2022

Copied

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);``````

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more New Here ,
Jun 28, 2022 Jun 28, 2022

Copied

LATEST

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)

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more   Resources
Troubleshooting FAQs
After Effects Community Recap
Getting started with After Effects