I've been struggling to calculate the accelerator. I've spend a whole day in searching, trial & error but all in vain. I've one horizontal line on the stage (AS3) of let say 200 width. Center-point of that line is on 60 (if it was 100, I would have surely done it by just calculating the percentage). Now I need to know the width of given percentage. For example, total width of 60% or where will 30% (or any other percentage) start from?
What I know is the total width, and the center-point (either in percentage or in width).
Your help will be highly appreciated. In case if there is any formula, please give me details, don't just mention a/b/c as I'd never been a student of physics :(
Edit:
I don't have 10 reputations, so I can't post image directly here. Please click the following link to see the image.
Link: http://oi62.tinypic.com/11sk183.jpg
Edit:
Here is what I want exactly: I want to travel n% from any point (A/B/C/D) to its relative point (A->B/A->D ...) (Link) http://i59.tinypic.com/2wp2lbl.jpg
If I understand correctly, you want a non-linear scale, so that pixel 1 on the line is 0%, pixel 100 on the line is 60% and pixel 200 is 100%?
If x=pixelpos/200 is the relative position on the line, one easy variation of the linear scale y=x*100% is y=(x+a*x*(1-x))*100%.
For x=0.5 the value is y=0.5+a*0.25, so for that to be 0.6=60% one needs a=0.4.
To get in the reverse direction the x for y=0.3=30%, one needs to solve a quadratic equation y=x*(1+a*(1-x)) or a*x^2-(1+a)*x+y=0. With the general solution formula, this gives
x = (1+a)/(2*a)-sqrt((1+a)^2-4*a*y)/(2*a)
= (2*y) / ( (1+a) + sqrt((1+a)^2-4*a*y) )
= (2*y) / ( (1+a) + sqrt((1-a)^2+4*a*(1-y)) )
and with a=0.4 and y=0.3
x = 0.6/( 1.4 + sqrt(1.98-0.48) )
approx 0.6/2.6=3/13=231/1001 approx 0.23
corresponding to pixel 46.
This will only work for a between -1 and 1, since for other values the slope at x=0 or x=1 will not be positive.
Another simple formula uses hyperbola instead of parabola,
y=a*x/(1+(a-1)*x)
with the inversion by
y+(a-1)*x*y = a*x <=> y = (a-(a-1)*y)*x
x = (y/a)/(1+(1/a-1)*y)
and
a = (y*(1-x))/(x*(1-y))
here there is no problem with monotonicity as long as there is no pole for x in [0,1], which is guaranteed for a>0.