0
$\begingroup$

In a simple example Plot3D shows a triangular mesh:

pic = Plot3D[Sin[x] Sin[y], {x, 0, 1}, {y, 0, 1}, Mesh -> All]

enter image description here

I know how to get the point-coordinates and the vertexnormals of this plot:

p = pic[[1, 1]][[1]]; (* points*)
n = VertexNormals /. pic[[1, 1]][[3]]; (* vertex normals*)

But I didn't get the 2D-elements of the surfaces

poly=Cases[Normal[pic], Polygon[pp_ ]  :> pp, All] (*returns  {} *)

My questions:

How can I get the element infomation?

Is there a more elegant way to get the informations p,n,poly from the plot?

Thanks!

$\endgroup$
2
  • 1
    $\begingroup$ Are you looking for Cases[Normal[pic], Polygon[pp_, _] :> pp, All]? $\endgroup$
    – Domen
    Commented Mar 1, 2022 at 13:11
  • $\begingroup$ @Domen Thanks, that's it. But the number of polygons (422) is much greater than the number of vertexnormals (249)? What's wrong here? $\endgroup$ Commented Mar 1, 2022 at 13:16

1 Answer 1

1
$\begingroup$

What's wrong with DiscretizeGraphics?

pic = Plot3D[Sin[x] Sin[y], {x, 0, 1}, {y, 0, 1}, Mesh -> All];
DiscretizeGraphics[pic]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks, good idea. I can use MeshCells[..,0], MeshCells[..,2] to get points and polygons. Easy transformation back to normalform(coordinates) is not clear to me yet. Besides, I don't understand why there are more polygons than points? $\endgroup$ Commented Mar 2, 2022 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.