Just need to change one line
Code:
$dist = 0.489235*($dr * $dr) + 0.693315*($dg * $dg) + 0.213092*($db * $db)
- 0.197458*($dr * $dg) - 0.183012*($dr * $db) - 0.015172*($dg * $db);