# Map values 0:90 to 2:0

I have values that range from 0 and 90, and I need to map their values to between 2 and 0. Examples would be 90 = 2, 0 = 0, 45 = 1. How can I go about getting these values converted down to the proper range?

Edit: I messed up on my examples.

Examples should be: 90 = 0, 0 = 2, 45 - 1

Use a straight line with equation:

$$y=2-\frac{1}{45}x$$

A general recipe is as follows:

Suppose that you have two points $(x_1,y_1)$ and $(x_2, y_2)$ and you need to identify a straight line that goes through those points. The equation for a straight line can be written as: $y = mx+c$ where $m$ is the slope and $c$ is the $y$-axis intercept when $x=0$.

Thus, we have:

$y_1 = mx_1+c$

and

$y_2 = mx_2 +c$

Solving the above system of equations gives us:

$m = \frac{y_2-y_1}{x_2-x_1}$

and

$c = y_1 - \frac{y_2-y_1}{x_2-x_1}x_1$

• Thank you for your answer, but I made a mistake in my question, please see my edits. Jun 20, 2013 at 3:45
• Updated. I imagine that you want $1$ for $45$. Jun 20, 2013 at 3:47
• Perfect. Thank you for the speedy, and accurate answer. Jun 20, 2013 at 4:01