Skip to content

Instantly share code, notes, and snippets.

@eliheuer
Created August 31, 2023 18:18
Show Gist options
  • Select an option

  • Save eliheuer/89a8be6eabde131a2b7f0b0da3483b24 to your computer and use it in GitHub Desktop.

Select an option

Save eliheuer/89a8be6eabde131a2b7f0b0da3483b24 to your computer and use it in GitHub Desktop.

Revisions

  1. eliheuer created this gist Aug 31, 2023.
    15 changes: 15 additions & 0 deletions vf-normalize.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    def remap(value, inputMin, inputMax, outputMin, outputMax):
    inputSpan = inputMax - inputMin # FIND INPUT RANGE SPAN
    outputSpan = outputMax - outputMin # FIND OUTPUT RANGE SPAN
    valueScaled = float(value - inputMin) / float(inputSpan)
    return outputMin + (valueScaled * outputSpan)


    test01 = remap(0, -100, 100, 20, 250)
    print(test01)

    test02 = remap(-100, -100, 100, 20, 250)
    print(test02)

    test03 = remap(100, -100, 100, 20, 250)
    print(test03)