找到你要的答案

Q:Formula for non-linear graph. The further you slide, the less it moves

Q:非线性图的公式。你滑的越远,它移动的越少

There's a name for a graph that does this, and I am trying to figure out an algorithm that calculates a result based on a DOUBLE input.

Like this: https://www.montereyinstitute.org/courses/Algebra1/COURSE_TEXT_RESOURCE/U03_L2_T5_text_final_files/image008.gif

I am trying to create a method that accomplishes what you see in apps that basically slows down velocity the further you pull. So for instance, if you slide your finger, a box appears easily, but then the further you pull, the slower it moves.

The full requirement is to have a "free pull" amount, i.e.: it's a 1:1 relationship where the amount you slide your finger, the output value is that much as well. And have a theoretical "max result", which I assume is theoretical, because the more your finger moves, the smaller the amount changes by.

I have a feeling there is a formula for this. So any Maths guys, please help :)

有一个图的名称,这样做,我试图找出一个算法计算结果的基础上双输入。

Like this: https://www.montereyinstitute.org/courses/Algebra1/COURSE_TEXT_RESOURCE/U03_L2_T5_text_final_files/image008.gif

我试图创建一个方法,实现你看到的应用程序,基本上减慢速度进一步拉。例如,如果你滑动手指,一个盒子很容易出现,但是你拉得越远,动作越慢。

全部的要求就是要有“自由拉”量,即:它是1:1的关系,量你手指滑动,输出值是多少以及。有一个理论上的“最大结果”,我假设是理论,因为你的手指移动越多,量的变化越小。

我感觉有一个公式。所以任何数学的家伙,请帮助:

answer1: 回答1:

You will have to try and see which formula works best for you.

Let's say the length of a finger pull is D and the distance of how far the box moves is D'. You can start with something very simple, like:

D' = D / 2

Then if you need some "free pull" distance of F, you would probably include it like this:

D' = if D < F
     then D
     else F + (D - F) / 2

To see which behavior of D' works best, you'll need to try different formulas. For example, a square root:

D' = if D < F
     then D
     else F + sqrt(D - F)

Edit: Here's a version with an upper boundary of F + M. It works because arctan's upper asymptote is Pi/2.

D' = if D < F
     then D
     else F + arctan((D - F) / M) * M * (2 / Pi)

Sample graph for F = 5, M = 3.D' will never reach 8 in this example.

你必须试着看看哪个公式对你最有效。

比如说,手指拉的长度是d,盒子移动的距离是多少。你可以从一些非常简单的事情开始,比如:

D' = D / 2

然后,如果你需要一些“自由拉”的距离F,你可能会包括它这样:

D' = if D < F
     then D
     else F + (D - F) / 2

要查看D的哪个行为最好,你需要尝试不同的公式。例如,平方根:

D' = if D < F
     then D
     else F + sqrt(D - F)

编辑:这是一个版本的上边界的F + M.它是因为反正切的上渐近线是π/ 2。

D' = if D < F
     then D
     else F + arctan((D - F) / M) * M * (2 / Pi)

样本图为F = 5,M = 3。d将永远不会达到8这个例子。

c#  formula  nonlinear-functions