Looks like a simple graphic task.

Currently, I have a control to which I need to add a tool for applying various acuity (or sensitivity). The problem is best illustrated as an image:

Graph http://img87.imageshack.us/img87/7886/control.png

As you can see, I have X and Y axess, both have arbitrary limits of 100 - this should be enough for this explanation. Currently my control is the red line (linear behavior), but I would like to add the ability to the other 3 curves (or more), i.e. if the control is more sensitive, then the installation will ignore the linear adjustment and switch to one of the three lines. The starting point will always be 0, and the ending point will always be 100.

I know that exponential is too steep, but it cannot seem that it is moving forward. Any suggestions please?

+4
source share
6 answers

The curves you illustrated are very similar to the gamma correction curves . The idea is that the minimum and maximum of the range remain the same as the input, but the middle is bent, as you have on the graphs (which I could notice, this is not a circular arc that you will get from the implementation of the cosine).

Graphically, it looks like this:

alt text http://upload.wikimedia.org/wikipedia/commons/thumb/7/74/GammaFunctionGraph.svg/200px-GammaFunctionGraph.svg.png

So, with this, like inspiration, here is the math ...

If your x values ​​ranged from 0 to 1, the function is pretty simple:

y = f(x, gamma) = x ^ gamma 

Add the xmax value for scaling (i.e., from x = 0 to 100) and the function will become:

 y = f(x, gamma) = ((x / xmax) ^ gamma) * xmax 

or alternatively:

 y = f(x, gamma) = (x ^ gamma) / (xmax ^ (gamma - 1)) 

You can do this even further if you want to add a nonzero xmin.

When gamma is 1, the line is always perfectly linear (y = x). If x is less than 1, your curve tilts up. If x is greater than 1, your curve deviates downward. The returned gamma value converts the value back to the original (x = f (y, 1 / g) = f (f (x, g), 1 / g).

Just adjust the gamma value according to your own taste and needs of the application. Since you want to provide the user with several “sensitivity enhancement” options, you may want to give users a choice on a linear scale, say, from -4 (least sensitive) to 0 (no change) to 4 (most sensitive) and scale your internal gamma values ​​with using the power function. In other words, give the user a choice (-4, -3, -2, -1, 0, 1, 2, 3, 4), but translate this value into the gamut (5.06, 3.38, 2.25, 1.50, 1.00, 0.67 0.44, 0.30, 0.20).

Coding in C # might look something like this:

 public class SensitivityAdjuster { public SensitivityAdjuster() { } public SensitivityAdjuster(int level) { SetSensitivityLevel(level); } private double _Gamma = 1.0; public void SetSensitivityLevel(int level) { _Gamma = Math.Pow(1.5, level); } public double Adjust(double x) { return (Math.Pow((x / 100), _Gamma) * 100); } } 

To use it, create a new SensitivityAdjuster, set the sensitivity level according to your preferences (either using the constructor, or using the method, and from -4 to 4 are likely to be reasonable level values) and call Adjust (x) to get adjusted output value. If you needed a wider or narrower range of reasonable levels, you would decrease or increase this value of 1.5 in the SetSensitivityLevels method. And of course, 100 represents your maximum x value.

+3
source

I offer a simple formula that (I believe) reflects your requirement. To have a full “quarter circle”, which is your last resort, you would use (1-cos((x*pi)/(2*100)))*100 .

I suggest that you take a weighted average between y = x and y = (1-cos ((x * pi) / (2 * 100))) 100. For example, to be very close to linear (99% linear), take :

 y = 0.99*x + 0.01*[(1-cos((x*pi)/(2*100)))*100] 

Or, more generally, let's say that the level of linearity is L, and in the interval [0, 1] your formula will be:

 y = L*x + (1-L)*[(1-cos((x*pi)/(2*100)))*100] 

EDIT: I changed cos(x/100) to cos((x*pi)/(2*100)) because for the result of cos in the range [1,0] X should be in the range [0, pi / 2] , not [0,1], sorry for the initial mistake.

+1
source

You are probably looking for something like polynomial interpolation . Quadratic / cubic / quartic interpolation should give you the kind of curves you see in the question. The differences between the three curves you show are likely to be achieved only by adjusting the coefficients (which indirectly determine the slope).

0
source

The graph y = x^p for x from 0 to 1 will do what you want when you change p from 1 (which will give a red line) up. As p increases, the curve will be “pushed” more and more. p does not have to be an integer.

(You need to scale to get from 0 to 100, but I'm sure you can do it)

0
source

I will vote for the general idea of ​​Rax Olgud with one modification:

 y = alpha * x + (1-alpha)*(f(x/100)*100) 

alt text http://www4c.wolframalpha.com/Calculate/MSP/MSP4501967d41e1aga1b3i00004bdeci2b6be2a59b?MSPStoreType=image/gif&s=6

where f (0) = 0, f (1) = 1, f (x) is super linear, but I don’t know where this quarter circle idea came from or why 1-cos (x) is a good choice.

I would suggest f (x) = x k where k = 2, 3, 4, 5, which gives the desired level of slope for? = 0. Choose a value for k as a fixed number, then? to select your curve.

0
source

For such problems, I often get a few points from the curve and throw it through the curve fitting program. There are many of them. Here is one with a 7 day free trial.

I learned a lot by trying different models. Often you can get a pretty simple expression that approximates your curve.

0
source

Source: https://habr.com/ru/post/1286710/


All Articles