Consider the following code:
ListPointPlot3D[
Flatten[#, 1] &@
Table[{x, y, 1}, {x, 0, 5, 5/60}, {y, Sin[x], Cos[x] + 3, (
Cos[x] + 3 - Sin[x])/60}], PlotRange -> All]
If I change ListPointPlot3D
to ListPlot3D
, I get the following:
Apparently, ListPlot3D
connects the points not in an expected way.
How to plot the set so that the neighboring points were connected with each other, not the far ones?
Answer
If the points form a deformed rectangular grid, then you can use the method below; otherwise, the methods of the following question should work:
DelaunayMesh in a specified closed region - creating a concave hull from a set of points
For a tensor grid of points:
pts = N@Table[{x, y, Cos[x] Sin[y]}, (* varying height *)
{x, 0, 5, 5/60},
{y, Sin[x], Cos[x] + 3, (Cos[x] + 3 - Sin[x])/60}];
With[{p = Flatten[pts, 1]},
Graphics3D[
GraphicsComplex[
p,
{EdgeForm[], ColorData[97][2],
Polygon[
Flatten[#][[{1, 2, 4, 3}]] & /@ Flatten[Partition[
Partition[Range@Length@p, Length@First@pts],
{2, 2}, {1, 1}],
1]
]}
]]]
It works even better if the height is a constant 1
.
Comments
Post a Comment