Arturo O. answered 01/18/18
Tutor
5.0
(66)
Experienced Physics Teacher for Physics Tutoring
You can try fitting a linear function.
f(x) = ax + b
f(0) = -1
f(1) = 1
Now solve for a and b.
f(0) = -1
-1 = a(0) + b ⇒
b = -1
f(1) = 1
a(1) + b = 1
a -1 = 1
a = 2
f(x) = 2x -1
Arturo O.
Are you familiar with linear equations? (I do not know what level of math you are at.) What I did was create a linear equation that transforms the range of 0→1 to -1→1. The equation also spreads out the values between 0 and 1 so they end up proportionally spaced between -1 and 1. Test the equation
f(x) = 2x - 1
and see that when x=0, f(x) = -1, i.e. it converts 0 to 1. Similarly, when x = 1, f(x)=1, so 1 remains 1. Any x between 0 and 1 will get converted to a value between -1 and 1. Also note that when x = 1/2 (i.e. x is in the middle), f(x) = 0, which is another result that you want. In your programming, you need to add a statement that converts the position (which is between 0 and 1) to a new position between -1 and 1, with the middle position going to 0. The equation I gave does that.
converted position = 2(old position) - 1
Report
01/19/18
Bryan M.
01/18/18