Created
April 1, 2016 14:58
-
-
Save lahwran/b262f62edadf470d208246294d2f8230 to your computer and use it in GitHub Desktop.
This file contains 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
from mpmath import mp, sqrt, atan2 | |
mp.dps = 250 | |
luv_good = mp.mpf("36.14585083971970000000000000000000"), mp.mpf("0.00000000000179982851973451000000"), mp.mpf("0.00000000000059994283991150500000") | |
luv_bad = mp.mpf("36.14585083971970000000000000000000"), mp.mpf("0.00000000000178678628408426000000"), mp.mpf("0.00000000000062602731121200500000") | |
lch_good = mp.mpf("36.14585083971970000000000000000000"), mp.mpf("0.00000000000189718584003013000000"), mp.mpf("18.43494882292200000000000000000000") | |
lch_bad = mp.mpf("36.14585083971970000000000000000000"), mp.mpf("0.00000000000189328165347235000000"), mp.mpf("19.30867293488920000000000000000000") | |
def sub(a, b): | |
for x, y in zip(a, b): | |
print " ", x - y | |
def convert(L, U, V): | |
iss = [L, U, V] | |
iss.append(U * U) | |
iss.append(V * V) | |
C = sqrt(iss[-2] + iss[-1]) | |
iss.append(C) | |
Hrad = atan2(V, U) | |
iss.append(Hrad) | |
H = Hrad * mp.mpf("180.0") | |
iss.append(H) | |
H = H / mp.mpf("3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091") | |
iss.append(H) | |
if H < mp.mpf("0"): | |
H = mp.mpf("360") + H | |
iss.append(H) | |
return (L, C, H), iss | |
lch_result_good, iss_g = convert(*luv_good) | |
lch_result_bad, iss_b = convert(*luv_bad) | |
print "good deltas: " | |
sub(lch_result_good, lch_good) | |
print "bad deltas: " | |
sub(lch_result_bad, lch_bad) | |
print "algo deltas: " | |
sub(iss_g, iss_b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment