in the above image I have shown two rectangles
float transformValue (float x,float A,float B, float C, float D){ return C + ((x-A) * (D-C)/(B-A)); }