Skip to content

Commit

Permalink
Refactor decision of contour levels into its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Lycken committed Nov 3, 2014
1 parent ff8c309 commit 7bded64
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Contour.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ function contour(x, y, z, level::Number)
end
contours(x,y,z,levels) = [contour(x,y,z,l) for l in levels]
function contours(x,y,z,Nlevels::Integer)
zmin,zmax = extrema(z)
dz = (zmax-zmin) / (Nlevels+1)
levels = range(zmin+dz,dz,Nlevels)
contours(x,y,z,levels)
contours(x,y,z,contourlevels(z,Nlevels))
end
contours(x,y,z) = contours(x,y,z,10)

function contourlevels(z,n)
zmin,zmax = extrema(z)
dz = (zmax-zmin) / (n+1)
range(zmin+dz,dz,n)
end

function coordinates(c::Curve2)
N = length(c.vertices)
xlist = Array(Float64,N)
Expand Down

0 comments on commit 7bded64

Please sign in to comment.