Visa ett inlägg
Oläst 2009-10-01, 16:24 #2
Bjorne Bjorne är inte uppkopplad
Flitig postare
 
Reg.datum: Sep 2009
Inlägg: 374
Bjorne Bjorne är inte uppkopplad
Flitig postare
 
Reg.datum: Sep 2009
Inlägg: 374
Din beskrivning är någorlunda vag ... men här är mitt försök.
Kod:
def transform(a, b1, b2, c1, c2):
    delta_b = b2 - b1
    dist_b = a - b1
    scale = float(dist_b) / delta_b
    delta_c = c2 - c1
    dist_c = delta_c * scale
    return c1 + dist_c

print transform(2, 0, 10, 0, 1000)
Bjorne är inte uppkopplad   Svara med citatSvara med citat