c42f / Displaz.jl

Julia bindings for the displaz lidar viewer
Other
16 stars 16 forks source link

Displaz clashes with common plotting APIs #8

Open andyferris opened 8 years ago

andyferris commented 8 years ago

Just a personal opinion - but would it make more sense to call the function displaz() instead of plot3d(), like the command line displaz? There seems to be export clashes with other common plotting packages. (What might make more sense is to add a Displaz backend to Plots.jl, if we want to think of displaz as a plotter)

c42f commented 8 years ago

Ugh, it didn't clash when I started using the name plot3d :-(

Making it a backend to Plots.jl would make sense, provided there's enough commonality. I just haven't done the hard work to make both talk to each other. Presumably the result would be the ability to use Plots.jl for some of the simple things, where for the more complex displaz-specific stuff, you'd just use displaz-specific APIs directly.

One thing I wanted to achieve was to make arbitrary per-vertex attributes work smoothly (probably via PointClouds.jl, or by taking an abstract table of some kind). Plots.jl has its own opinions on this kind of thing, not sure if they're compatible.

c42f commented 8 years ago

Which package does it clash with by the way?

andyferris commented 8 years ago

I've been thinking about naming conventions in Displaz, and I'm begining to believe the solution might be in not exporting any commands at all, and choosing simple names, like this:

# Plot some data
Displaz.plot(pos; label = "data1", color = colors)

# Make first 10 points red
Displaz.mutate!([1:10...]; label = "data1", color = [1.0, 0.0, 0.0])

It's quite readable and the typing isn't too bad.

tbreloff commented 8 years ago

Hey @c42f I would love to have something for super-fast point clouds without too many bells and whistles (as a Plots backend I mean). If we commit to only supporting the bare minimum of functionality, it would be pretty straightforward to add as a backend. I'll have to check out the package in more detail.

c42f commented 8 years ago

Thanks Tom! I'm definitely keen to make this happen if possible. I did want to chat with you at juliacon, but with so much else going on I just missed the opportunity.

Last time I looked at Plots.jl there seemed to be a strong preference to split the components of position x,y as separate arguments to the plot functions. In point cloud land, I really want position information to come in a single array - either as a vector of 3-vectors (eg, Vector{StaticArrays.SVector{3,Int}}) or as a matrix (3xN or Nx3, there's arguments for both conventions). Obviously that wouldn't prevent us from making a useful Plots.jl backend, but it would be enough to make me use a Displaz-specific API when working with point clouds. Is this something we could have in the existing interface or does it break too many assumptions?

To roughly outline where I'm thinking of going with the julia interface for displaz (including lines and 2D meshes), I'm imagining a low level plotting function, something like


displaz([window,] [topology,] vertex_positions; label=nothing, shader=nothing, extra_attributes)

Plot a 3D primitive composed of vertices located at vertex_positions. By default, the vertices are assumed to represent a set of zero dimensional points, and plotted as a point cloud. However, the topology argument may be used to indicate connectivity between vertices, which allows lines and surfaces to be plotted. The data set will be plotted into the supplied window (Displaz.current() by default).

Vertices may be styled by attaching arbitrary extra attributes per vertex, such as color, marker shape and size. These make their way into the OpenGL shader program as per-vertex variables of the same name, and may be used in the shader for fine control over the rendering process.


Higher level functions would then be built on top of that. So, I'm thinking that:

As a side note, data set labels have a fairly special place in displaz at the moment - they serve as handles to modify geometry, replace it, unload it, etc.

c42f commented 8 years ago

Another note, the displaz summary documentation is super bad at the moment, but the function documentation is actually ok. So if you're looking at this package, ?plot3d will help you a lot more than reading the README at this stage.

mkborregaard commented 7 years ago

The plot3d and plot3d! names are also exported from Plots, so there's a clash there. Not sure how often people would have these loaded at the same time. I think a Plots backend, if that's still on the table, would simply check that the input data were appropriate, that the seriestype was scatter, and then pass that and the colors in whatever format most preferred by displaz. It could be nice to have super-fast display of very big point clouds.