color-lab: fix all expt calls to use float type
authorJulien Danjou <julien@danjou.info>
Wed, 24 Nov 2010 08:35:45 +0000 (09:35 +0100)
committerJulien Danjou <julien@danjou.info>
Wed, 24 Nov 2010 08:35:45 +0000 (09:35 +0100)
Signed-off-by: Julien Danjou <julien@danjou.info>
lisp/ChangeLog
lisp/color-lab.el

index cc0bfe1..a74389e 100644 (file)
@@ -1,3 +1,7 @@
+2010-11-24  Julien Danjou  <julien@danjou.info>
+
+       * color-lab.el: Fix all expt calls to use float type.
+
 2010-11-24  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * shr.el (shr-insert-color-overlay): Pass rgb(rrr, ggg, bbb) type color
index c5a953c..35e75d4 100644 (file)
@@ -153,14 +153,14 @@ none is set, `color-lab-d65-xyz' is used."
       (let* ((fy (/ (+ L 16) 116.0))
              (fz (- fy (/ b 200.0)))
              (fx (+ (/ a 500.0) fy))
-             (xr (if (> (expt fx 3) color-lab-ε)
-                     (expt fx 3)
+             (xr (if (> (expt fx 3.0) color-lab-ε)
+                     (expt fx 3.0)
                (/ (- (* fx 116) 16) color-lab-κ)))
              (yr (if (> L (* color-lab-κ color-lab-ε))
-                     (expt (/ (+ L 16) 116.0) 3)
+                     (expt (/ (+ L 16) 116.0) 3.0)
                    (/ L color-lab-κ)))
              (zr (if (> (expt fz 3) color-lab-ε)
-                     (expt fz 3)
+                     (expt fz 3.0)
                    (/ (- (* 116 fz) 16) color-lab-κ))))
         (list (* xr Xr)                 ; X
               (* yr Yr)                 ; Y
@@ -186,14 +186,14 @@ Colors must be in CIE L*a*b* format."
       (let* ((kL (or kL 1))
              (kC (or kC 1))
              (kH (or kH 1))
-             (C₁ (sqrt (+ (expt a₁ 2) (expt b₁ 2))))
-             (C₂ (sqrt (+ (expt a₂ 2) (expt b₂ 2))))
+             (C₁ (sqrt (+ (expt a₁ 2.0) (expt b₁ 2.0))))
+             (C₂ (sqrt (+ (expt a₂ 2.0) (expt b₂ 2.0))))
              (C̄ (/ (+ C₁ C₂) 2.0))
-             (G (* 0.5 (- 1 (sqrt (/ (expt C̄ 7) (+ (expt C̄ 7) (expt 25 7)))))))
+             (G (* 0.5 (- 1 (sqrt (/ (expt C̄ 7.0) (+ (expt C̄ 7.0) (expt 25 7.0)))))))
              (a′₁ (* (+ 1 G) a₁))
              (a′₂ (* (+ 1 G) a₂))
-             (C′₁ (sqrt (+ (expt a′₁ 2) (expt b₁ 2))))
-             (C′₂ (sqrt (+ (expt a′₂ 2) (expt b₂ 2))))
+             (C′₁ (sqrt (+ (expt a′₁ 2.0) (expt b₁ 2.0))))
+             (C′₂ (sqrt (+ (expt a′₂ 2.0) (expt b₂ 2.0))))
              (h′₁ (if (and (= b₁ 0) (= a′₁ 0))
                       0
                     (let ((v (atan b₁ a′₁)))
@@ -232,15 +232,15 @@ Colors must be in CIE L*a*b* format."
                    (* 0.24 (cos (* h̄′ 2)))
                    (* 0.32 (cos (+ (* h̄′ 3) (degrees-to-radians 6))))
                    (- (* 0.20 (cos (- (* h̄′ 4) (degrees-to-radians 63)))))))
-             (Δθ (* (degrees-to-radians 30) (exp (- (expt (/ (- h̄′ (degrees-to-radians 275)) (degrees-to-radians 25)) 2)))))
-             (Rc (* 2 (sqrt (/ (expt C̄′ 7) (+ (expt C̄′ 7) (expt 25 7))))))
-             (Sl (+ 1 (/ (* 0.015 (expt (- L̄′ 50) 2)) (sqrt (+ 20 (expt (- L̄′ 50) 2))))))
+             (Δθ (* (degrees-to-radians 30) (exp (- (expt (/ (- h̄′ (degrees-to-radians 275)) (degrees-to-radians 25)) 2.0)))))
+             (Rc (* 2 (sqrt (/ (expt C̄′ 7.0) (+ (expt C̄′ 7.0) (expt 25.0 7.0))))))
+             (Sl (+ 1 (/ (* 0.015 (expt (- L̄′ 50) 2.0)) (sqrt (+ 20 (expt (- L̄′ 50) 2.0))))))
              (Sc (+ 1 (* C̄′ 0.045)))
              (Sh (+ 1 (* 0.015 C̄′ T)))
              (Rt (- (* (sin (* Δθ 2)) Rc))))
-        (sqrt (+ (expt (/ ΔL′ (* Sl kL)) 2)
-                 (expt (/ ΔC′ (* Sc kC)) 2)
-                 (expt (/ ΔH′ (* Sh kH)) 2)
+        (sqrt (+ (expt (/ ΔL′ (* Sl kL)) 2.0)
+                 (expt (/ ΔC′ (* Sc kC)) 2.0)
+                 (expt (/ ΔH′ (* Sh kH)) 2.0)
                  (* Rt (/ ΔC′ (* Sc kC)) (/ ΔH′ (* Sh kH)))))))))
 
 (provide 'color-lab)