Last active
September 7, 2021 04:50
-
-
Save JohnForbes/7130661 to your computer and use it in GitHub Desktop.
Interpolation Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bituAsphHueMax = 100.0 | |
bituAsphHueMean = 50.0 | |
bituAsphHueMin = 0.0 | |
bituAsphLumMax = 100.0 | |
bituAsphLumMean = 50.0 | |
bituAsphLumMin = 0.0 | |
bituAsphSatMax = 100.0 | |
bituAsphSatMean = 50.0 | |
bituAsphSatMin = 0.0 | |
brickPavHueMax = 100.0 | |
brickPavHueMean = 50.0 | |
brickPavHueMin = 0.0 | |
brickPavLumMax = 100.0 | |
brickPavLumMean = 50.0 | |
brickPavLumMin = 0.0 | |
brickPavSatMax = 100.0 | |
brickPavSatMean = 50.0 | |
brickPavSatMin = 0.0 | |
concreteHueMax = 100.0 | |
concreteHueMean = 50.0 | |
concreteHueMin = 0.0 | |
concreteLumMax = 100.0 | |
concreteLumMean = 50.0 | |
concreteLumMin = 0.0 | |
concreteSatMax = 100.0 | |
concreteSatMean = 50.0 | |
concreteSatMin = 0.0 | |
grassTurfHueMax = 100.0 | |
grassTurfHueMean = 50.0 | |
grassTurfHueMin = 0.0 | |
grassTurfLumMax = 100.0 | |
grassTurfLumMean = 50.0 | |
grassTurfLumMin = 0.0 | |
grassTurfSatMax = 100.0 | |
grassTurfSatMean = 50.0 | |
grassTurfSatMin = 0.0 | |
hue = 20.0 | |
sat = 30.0 | |
lum = 40.0 | |
def trueInterpolate(x,xmin,xmax,ymin,ymax): | |
return ymin+(ymax-ymin)*((x-xmin)/(xmax-xmin)) | |
def interpolate(x,xmin,xmax): | |
return ((x-xmin))/(xmax-xmin) | |
def distance3d(xa,ya,za,xb,yb,zb): | |
return ((xb-xa)**2 + (yb-ya)**2 + (zb-za)**2)**0.5 | |
def distance2d(xa,ya,xb,yb): | |
return ((xb-xa)**2 + (yb-ya)**2)**0.5 | |
def distance(xa,xb): | |
return xb-xa | |
def chooseScore(x,maximum,mean,minimum): | |
print x, maximum, mean, minimum | |
if distance(x,mean) > 0: | |
print "interpolate relative to min" | |
return interpolate(x,minimum,mean) | |
else: | |
print "interpolate relative to max" | |
return interpolate(x,maximum,mean) | |
hueScore = chooseScore(hue,grassTurfHueMax,grassTurfHueMean,grassTurfHueMin) | |
satScore = chooseScore(sat,grassTurfSatMax,grassTurfSatMean,grassTurfSatMin) | |
lumScore = chooseScore(lum,grassTurfLumMax,grassTurfLumMean,grassTurfLumMin) | |
#score = (hueScore + satScore+ lumScore)/3 | |
score = 1-distance3d(hueScore,satScore,lumScore,1,1,1)/(3**0.5) | |
print hueScore, satScore, lumScore | |
print score |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment