Skip to content

Commit

Permalink
use integer type better.
Browse files Browse the repository at this point in the history
  • Loading branch information
Julia Longtin committed May 15, 2018
1 parent 1c801d6 commit 3fbca66
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Graphics/Implicit/Export/Render/Interpolate.hs
Expand Up @@ -7,9 +7,9 @@

module Graphics.Implicit.Export.Render.Interpolate (interpolate) where

import Prelude(Integer, (*), (>), (<), (/=), (+), (-), (/), (==), (&&), abs)
import Prelude((*), (>), (<), (/=), (+), (-), (/), (==), (&&), abs)

import Graphics.Implicit.Definitions (, ℝ2)
import Graphics.Implicit.Definitions (, , ℝ2)

-- Consider a function f(x):

Expand Down Expand Up @@ -43,6 +43,8 @@ import Graphics.Implicit.Definitions (ℝ, ℝ2)
-- If it doesn't cross zero, we don't actually care what answer we give,
-- just that it's cheap.

-- FIXME: accept resolution on multiple axises.

interpolate :: ℝ2 -> ℝ2 -> ( -> ) -> ->
interpolate (a,aval) (_,bval) _ _ | aval*bval > 0 = a

Expand Down Expand Up @@ -119,7 +121,7 @@ interpolate (a,aval) (b,bval) f _ =

-- Try the answer linear interpolation gives us...
-- (n is to cut us off if recursion goes too deep)
interpolateLin :: Integer -> ℝ2 -> ℝ2 -> ( -> ) ->
interpolateLin :: -> ℝ2 -> ℝ2 -> ( -> ) ->
interpolateLin n (a, aval) (b, bval) obj | aval /= bval=
let
-- Interpolate and evaluate
Expand Down Expand Up @@ -153,7 +155,7 @@ interpolateLin n (a, aval) (b, bval) obj | aval /= bval=
interpolateLin _ (a, _) _ _ = a

-- Now for binary searching!
interpolateBin :: Integer -> ℝ2 -> ℝ2 -> ( -> ) ->
interpolateBin :: -> ℝ2 -> ℝ2 -> ( -> ) ->

-- The termination case:

Expand Down

0 comments on commit 3fbca66

Please sign in to comment.