Tighter tension on curve?

For general discussion related FlowStone
Post Reply
shrunkyq
Posts: 15
Joined: Fri Aug 17, 2018 9:21 pm

Tighter tension on curve?

Post by shrunkyq »

I am working on a project, and I am trying to get the right curve on the tension. This is the code I have for it.

Code: Select all

def curve x, tension
    tn = [[0.5 * (tension+1.0), 0.999999].min, 0.000001].max
    t = 1.0 - (2.0*tn-1.0) / tn
    return (t!=1.0) ? (t**x-1.0) / (t-1.0) : x
end


What I am after is having a "tighter" tension, rather than having it stretch through the whole plot. This is new to me, so I am experimenting as much as I could. Here is a video example of how it looks and also how I want the curve to go: https://www.youtube.com/watch?v=g97tR-IRmdo

Could someone point to the right direction regarding this?

Many thanks!` :D
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Tighter tension on curve?

Post by martinvicanek »

The curve in the video looks like a rational function.
Suppose your x variable goes from 0 to 1.
Suppose you want to map this to y-values from 0 to 1.
Allow the midpoint x=0.5 to map to some y-valute t between 0 and 1.
So you have the following mapping table:

Code: Select all

x     y
-------
0     0
0.5   t
1     1


The general mapping formula would be:

y = t*x/(1 - t +(2t - 1)*x)

Obviously for t = 0.5 this results in the trivial mapping y = x as it should.
shrunkyq
Posts: 15
Joined: Fri Aug 17, 2018 9:21 pm

Re: Tighter tension on curve?

Post by shrunkyq »

Thank you Martin, I will definitely check this out!

martinvicanek wrote:The curve in the video looks like a rational function.
Suppose your x variable goes from 0 to 1.
Suppose you want to map this to y-values from 0 to 1.
Allow the midpoint x=0.5 to map to some y-valute t between 0 and 1.
So you have the following mapping table:

Code: Select all

x     y
-------
0     0
0.5   t
1     1


The general mapping formula would be:

y = t*x/(1 - t +(2t - 1)*x)

Obviously for t = 0.5 this results in the trivial mapping y = x as it should.
Post Reply