View Full Version : how to calculate in/out tangent in tackview

03 March 2012, 12:31 AM
Hey, i'm relatively new here and I really like how you guys keep helping each other, its nice too see that.

I'm currently trying to determine how to calculate and manipulate the in / out tangent of a given point.

What I'd like to do is set the out tangent of a point to match the hypothemuse of the triangle done with the next or the previous keys ( see attachment ( sorry for the bad drawing, I did it on my girfriend's laptop using the touchpad)). But in order to do that I need to first understand how to calculate those tangents.

I noticed a few post here about that but didnt really find the answer I was looking for.

I'm looking for a point value, not a point 2

I understand this magic number 0.1875 but how is it related to a 45 degree angle

I guess I missed something cause in the end it somehow seemed kinda obvious to those guys although they were converting tvc value to CCC

03 March 2012, 01:04 AM
no, no, no... not again. i remember... i've answered... i swear :(

03 March 2012, 12:15 PM
alright :) i'll try to go back to the old thread and try to figure out what I missed :) :blush:

03 March 2012, 12:43 PM
atan2 outTangent 0.1875

seems to give the appropriate answer, no idea why 0.1875 is the magic number.

03 March 2012, 05:53 PM
What is the angle if you can zoom x and y independently, and In/Out tangent value doesn't depend on next key position?
here is the same curve but different zoom: (

03 March 2012, 05:56 PM
yup indeed it does gives the angle
now I just need to reverse the process
although my understanding of math / scripting doesnt allow me to know how to inverse it
I think I do knows what atan2 does (thanks to google) but still dont know how to reverse it

What is the angle if you can zoom x and y independently, and In/Out tangent value doesn't depend on next key position?

i'm assuming that the angle between 2 keys isnt relative to the zoom.,, I might be totally wrong but as far as I know the tangent value doesnt change whether you zoom in or out even if the curve is stretching or squashing... so I assume the zoom is just somehow "stretching" the trackview viewport.

On the practical side it would be anoying if everytime you zoom in or out that would change your tangent value

03 March 2012, 06:50 PM
the "reverse" would be

outtangent = (y * 0.1875)/ (outlength * delta_frames )

i may get there in the end?

the 0.1875 could relate to 4800 ticks per second somehow (other than being equal to * 900)

03 March 2012, 08:19 PM
hmm didnt get the same results as using atan2

just to be sure y = y value in the track view ( the value of the next key) ? and delta frames the differences between the current frame and the next frames ( out tangent)

edit:outtangent = y value *.1875 / delta_frames seems to work.

I did get the desired tangent.... I'll do another test

SECOND EDIT: my second test seems to work although we should replace Y or Y value by delta Y ( see attachment) I used the out tangent value from the math and this is what I got ( and no matter how I zoom it stays the same ;)

so outtangent = (delta_Y*.1875)/delta_frames

btw this is working with a .5 tangent length setting

03 March 2012, 09:35 PM
y was the vertical offset to the handle from keyframe value

12 December 2012, 05:22 PM
Hello gents,

I'm a newbie on CGTalk and I'm also digging up an old topic, but I think I've got answers for unresolved questions here. I've read numerous threads which never gave a proper solution, so here is mine.
I'll try to be as clear as possible, though my mind is still pretty dazed. I'll just start by saying, Mr denisT, .1875 is definitely NOT a magic number ;)

I'm been working on an animation exporter for some days, finally facing the awful issues of bezier key tangents. I've spent like ten hours trying to figure out what was REALLY going on there, mostly on that .1875 value that I've found on every topic regarding those in/outTangent values. Fact is, this value stand as long as you don't change your time configuration.

I've finally understood the logic, as the outTangentValue is a percentage of the distance between the following key and the current key - let's call this distance, Delta. Delta is however a substraction between time values.
At this time, I understood that those tangent values relied on the frame rate. The frameRate value is linked to the ticksPerFrame value as ticksPerFrame * framerate = 4800. (cf. MAXScript help). And then, I've ended up finding our precious : .1875.

With a basic frame rate of 30fps, ticksperframe is therefore 4800./30 = 160.
BUT, here it comes : 30./160 = 0.1875.
This value will change if the frame rate change. For example, at 25fps, it's 0.130208.

I'm not quite sure of how I ended up on this, but here's the final & proper equation for an out tangent, which will give you the difference Y value between the key and the tangent point :

OutTangent_Yvalue = (
( outTangent * outTangentLength * Delta * ticksPerFrame ) / frameRate

Some trick here as Delta is the distance in frames between the current and the next keys. For instance, if the first key is on frame 5, and the second on frame 30, Delta equals 25. This calculation goes like this :

Delta = (
-- Gets the distance in frames between the keys as a Float value,
-- as Animation keys time values are float values.
-- A key can be set to a time like 19.5f.
( ( theKeys[i+1].time - theKeys[i].time ) as float / ticksPerFrame )

Hope I got it all right, once again I'm quite exhausted right now. Feel free to correct my points or explanations, but I'll stand on my formula ! =)
Hope it'll be useful to you all.

CGTalk Moderation
12 December 2012, 05:23 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.