Hi everybody, I'm trying to add an ease-in expression to a rig. I'm not really a math guy, so I'm referencing Penner's equation and in particular this doc: http://upshots.org/actionscript/jsas-understanding-easing.

My code for testing looks like this so far:

```
import c4d, math
#Welcome to the world of Python
start = 10 #start pos
end = 300 #end pos
d = 50 #duration
def easein(t,d) :
ratio = t/d
print "ratio: ",ratio
return math.pow(ratio,5)
def main() :
t = doc.GetTime().GetFrame(doc.GetFps()) #current frame
factor = easein(t,d)
out_pos = start + (end-start) * factor
print "t: ", t
print "d: ", d
print "factor: ", factor
print "out pos: ", out_pos
```

but the result of (t/d) is always 0.0. I guess is something with the values type but I can't figure it out.

What am I doing wrong?

Thanks for any advice or help!

cheers

massimiliano

Hi everybody, I'm trying to add an ease-in expression to a rig. I'm not really a math guy, so I'm referencing Penner's equation and in particular this doc: http://upshots.org/actionscript/jsas-understanding-easing.

My code for testing looks like this so far:

```
import c4d, math
#Welcome to the world of Python
start = 10 #start pos
end = 300 #end pos
d = 50 #duration
def easein(t,d) :
ratio = t/d
print "ratio: ",ratio
return math.pow(ratio,5)
def main() :
t = doc.GetTime().GetFrame(doc.GetFps()) #current frame
factor = easein(t,d)
out_pos = start + (end-start) * factor
print "t: ", t
print "d: ", d
print "factor: ", factor
print "out pos: ", out_pos
```

but the result of (t/d) is always 0.0. I guess is something with the values type but I can't figure it out.

What am I doing wrong?

Thanks for any advice or help!

cheers

massimiliano

Hi,

you are calculating the ratio as an integer division. Simple solution, either make d a float value (d = 50.0) or force the division to be calculated with floating point (ration = float(t) / float(d)).

Here's some information on Floating Point Arithmetic in the Python docs.

Please also note, Cinema 4D use a 2.7.x implementation of Python. There is a change in behavior of integer division compared to Python 3.x, see for example here.

Ahh, that makes sense. Thanks for the help!

Massimiliano