Open ChrisRackauckas opened 6 years ago
Does this work for you: http://makie.juliaplots.org/stable/functions.html#Mesh-1
Maybe? I don't understand the format. I'm used to see the indices as an 3xN matrix where each column denotes the indices for the i
th triangle. How is this interpreted?
We can have a simple recipe for this :)
e.g. just overload to_indices
to do the conversion... Do you happen to have a nice notebook or something, that I can port and make sure it works?
https://github.com/JuliaPlots/Plots.jl/issues/392#issuecomment-342238881
That was a good example. That JLD is on an old version of DiffEqProblemLibrary though: we might want to move that example over to here since I want to delete that sooner rather than later. Pin to v0.11.0
.
Ah, so I already demonstrated how to do it... we might want to have a recipe, that adds the additional wireframe
call to mesh
as an attribute!
I still don't get how the format is defined though.
What part?
The mesh is just vertices = Vector{Point{N, Float32}
&& triangles = Vector{GLTriangle}
where GLTriangle == Face{3, UInt32}
, where Points and Faces are static arrays... The face type has a lot of convenience defined for indexing, even if it's 0 indexed etc.
Your example code doesn't show Point
or GLTriangle
stuff though, just:
using Makie
using GLVisualize: loadasset, assetpath
scene = Scene(resolution = (500, 500))
x = [0, 1, 2, 0]
y = [0, 0, 1, 2]
z = [0, 2, 0, 1]
color = [:red, :green, :blue, :yellow]
i = [0, 0, 0, 1]
j = [1, 2, 3, 2]
k = [2, 3, 1, 3]
indices = [1, 2, 3, 1, 3, 4, 1, 4, 2, 2, 3, 4]
mesh(x, y, z, indices, color = color)
I'm not sure how indices is interpreted. Is that reshaped to a 3xN?
No, that's converted to vertices = Vector{Point{N, Float32}
&& triangles = Vector{GLTriangle}
How does the second one take place? Is every 3 a triangle?
Ah yeah, it is ;)
I mean, it's just reinterpret(Face{3, Int}, indices)
So then it is the same as thinking of it as the 3xN indices. This should be more explicit in the docs. So what's shown is actually a tetrahedron then? That angle doesn't show it.
I think the example should be reworked a little bit. I'll see if I can do that sometime sooner rather than later.
As far as a recipe, here's the two things a finite element recipe would need:
1) A 2D mesh. The values are (x,y) that are a triangular mesh of a space. But then there's a z value which is the value of the PDE at the triangular nodes. So this naturally is viewed as a trisurf plot like seen here:
https://scicomp.stackexchange.com/questions/10203/visualizing-finite-element-solutions-in-matlab
or just in a projection to show via only color.
2) A 3D mesh. In many cases the mesh might use 3D elements like tetrahedrons. In that case, it's (x,y,z,w), where w
is the PDE solution that denotes color. This is commonly denoted as a tetramesh plot, like:
https://www.mathworks.com/help/matlab/ref/tetramesh.html https://andreweib.wordpress.com/2010/12/14/element-aspect-ratio/
From this discussion it seems that the mesh
function is enough to build these tools. When the recipe system is created I can give this a go.
This gets mentioned quite a bit. Starting point:
https://github.com/JuliaPlots/Plots.jl/issues/392
I want to make sure it got on the issue list itself.