File: C:/xampp/htdocs/PSA112Tx/de00.php
<?php
# ------- The graph values in the form of associative array
function de00($l1,$a1,$b1,$l2,$a2,$b2) {
$d76=sqrt(pow(($l1-$l2),2)+ pow(($a1-$a2),2)+pow(($b1-$b2),2));
$cab1 = sqrt(pow($a1,2) + pow($b1,2));
$cab2 = sqrt(pow($a2,2) + pow($b2,2));
$meanc = ($cab1 + $cab2) / 2;
$logmeanc =log10($meanc);
$log25 = log10(25);
$cratio = sqrt(pow(10,($logmeanc*7 - log10((pow(10,($logmeanc*7)) + pow(10,($log25*7)))))));
$g = 0.5 * (1 - $cratio);
$a1 = (1 + $g) * $a1;
$a2 = (1 + $g) * $a2;
$cab1 = pow((pow($a1 , 2)+ pow($b1 , 2) ),0.5);
$cab2 = pow((pow($a2 , 2) + pow($b2 , 2) ),0.5);
$deltac = $cab1 - $cab2;
// ' calculate delta L*
$deltal = $l1 - $l2;
//';calculate hue angles
If ($b1 == 0) {
If ($a1 >= 0) {
$h1 = 0;}
Else {
$h1 = 180;}}
Else {
$h1 = rad2deg(atan2($b1, $a1));
}
If ($b2 == 0) {
If ($a2 >= 0) {
$h2 = 0;}
Else {
$h2 = 180; }
}
Else {
$h2 = rad2deg(atan2($b2, $a2));
}
If ($h1 < 0) {
$h1 = $h1 + 360;}
If ($h2 < 0) {
$h2 = $h2 + 360;}
// ' calculate delta h and mean h
$deltah = $h1 - $h2;
$meanh = $h1 + $h2;
If ($deltah > 180) {
$deltah = $deltah - 360;
$meanh = $meanh - 360;
}
If ($deltah < -180) {
$deltah = $deltah + 360;
$meanh = $meanh - 360;
}
$delth = 2 * pow(($cab1 * $cab2),0.5) * sin(deg2rad($deltah / 2));
$deltal = $l1 - $l2;
$deltaE = pow((pow($deltal,2) + pow($deltac,2) + pow($delth,2)),0.5);
$deltaha = pow($deltaE , 2)- pow($deltal , 2) - pow($deltac , 2);
If ($deltaha < 0) {
$deltaha = 0;
}
$delth = pow($deltaha , 0.5);
$delth = 2 * pow(($cab1 * $cab2),0.5) * sin(deg2rad($deltah / 2));
$meanl = ($l1 + $l2) / 2;
$meanc = ($cab1 + $cab2) / 2;
$meanh = $meanh / 2;
//' Computes the weighting functions.
$sl = 1 + ((0.015 * pow(($meanl - 50),2)) / pow((20 + pow(($meanl - 50),2)),0.5));
$sc = 1 + 0.045 * $meanc;
//' find the hue angle goodness
// ' split these up because I don't know how to split lines in vb
$t1 = 1 - 0.17 * cos(deg2rad($meanh - 30));
$t2 = 0.24 * cos(deg2rad(2 * $meanh));
$t3 = 0.32 * cos(deg2rad(3 * $meanh + 6));
$t4 = -0.2 * cos(deg2rad(4 * $meanh - 63));
$t = $t1 + $t2 + $t3 + $t4;
$sh = 1 + 0.015 * $meanc * $t;
$sr = $sc * $sh;
//same problem as above with the big numbers
$logmeanc = log10($meanc);
$log25 =log10(25);
$rc_numerator = pow(10 , ($logmeanc * 7));
$rc_denominator = $rc_numerator + pow(10 , ($log25 * 7));
$rc = 2 * pow(($rc_numerator / $rc_denominator) , 0.5);
$dthet = 30 * exp(-1 * pow((($meanh - 275) / 25) , 2));
$rt = -sin(2 * deg2rad($dthet)) * $rc;
// ' Now computes deltaV
$vl = pow(($deltal / $sl) , 2);
$vc = pow(($deltac / $sc) , 2);
$vh = pow(($delth / $sh) , 2);
$deltaE2000 = pow(($vl + $vc + $vh + ($rt * $deltac * $delth / $sr)) , 0.5);
return $deltaE2000;
//$deltaE2000=12.233;
//return round($d76,2);
//return $cab1;
}
?>