Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better access to the coordinates of a contour line #9

Closed
tomasaschan opened this issue Jul 7, 2014 · 3 comments
Closed

Provide better access to the coordinates of a contour line #9

tomasaschan opened this issue Jul 7, 2014 · 3 comments

Comments

@tomasaschan
Copy link
Contributor

Currently, there is no simple way to access the coordinates of the contour lines. It would be nice with something like

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

    for (i,v) in enumerate(c.vertices)
        xlist[i] = v[1]
        ylist[i] = v[2]
    end
    xlist, ylist
end

to be used as xs, ys = coordinates(line) but there might be an even better API for it. See also some discussion here: https://groups.google.com/forum/?fromgroups=#!topic/julia-users/yVKubPEoUYE

@darwindarak
Copy link
Collaborator

That looks good to me. Maybe we can also add a function to group the lines together:

function contour_lines(c::ContourLevel)
    N = length(c.lines)
    lines = Array(Vector{Float64}, Vector{Float64}, N)

    for (i, line) in enumerate(c.lines)
        lines[i] = coordinates(line)
    end

    return lines
end

@tomasaschan
Copy link
Contributor Author

@darwindarak I'm not sure that's a good idea, since you loose some information in the process - given the result of that function, there's no way of knowing which, if any, of the included vertices are "false" ones, connecting the ends of two lines rather than specifying a surface. And since, given coordinates, it's not so hard to do if you do want it, we could just as well let the user handle it =)

I'll go ahead and add coordinates.

@tomasaschan
Copy link
Contributor Author

Fixed by eb004be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants