Parametric Function for Coloring

58 Views Asked by At

I'm trying to write a parametric straightline function that changes its values between 0.529 and 0.933.

Usually what I would do is:

$r = 0.529+(0.933-0.529)*v$

where parameter $v= [0,1]$

This ensure that my r value will either be 0.529 or 0.933

However, due to some limitations my parameter $v$ has to be changed to $v=[-2,1]$

Is there anyway that I can change the straightline function such that it will still return r as either 0.529 or 0.933?

Thank you!

2

There are 2 best solutions below

0
On BEST ANSWER

Ok you want a transformation for $[-2,1]$ to $[0,1]$ then change $v$ for $(v+2)\frac{1}{3}$

The reasoning is the next, you want the $-2$ will be maped to $0$ and the $1$ to $1$, the easiest way is a line with slope: $$\frac{1-0}{1-(-2)}=\frac{1}{3}$$ Then the line equation will be: $$v'=0+\frac{1}{3}(v-(-2))$$ $$v'=\frac{1}{3}(v+2)$$

0
On

Change $v$ for $(v+2)/3$. This maps $-2$ to $0$ and $1$ to $1$.