Hot answers tagged mesh
18
You are combining the images in the form
Show[Graphics[simplePrimitives], complicatedRegionPlot]
The options in the resulting figure are inherited from the first term, namely Graphics[simplePrimitives]. This does not include the "TransparentPolygonMesh" -> True generated by RegionPlot. You see the mesh as a result. If you combine things as follows:
...
16
Here's my go at it.
This tells you if two line segments intersect (unless they lie on the same line, in which case it fails horribly):
ClearAll[segmentsIntersect];
segmentsIntersect[{a_, b_}, {p_, q_}] :=
Module[{s, t, soln},
soln = NSolve[a + t (b - a) == p + s (q - p), {s, t}];
If[Length@soln == 0, False, (0 <= s <= 1 && 0 <= t ...
13
It might be easier to use TriangularSurfacePlot3D to find the Delaunay triangulation of the points. For example,
Needs["ComputationalGeometry`"];
triangles[points_] := Module[{pl},
pl = TriangularSurfacePlot[ArrayPad[points, {{0, 0}, {0, 1}}]];
Cases[pl, Polygon[a_] :> Flatten[(Position[points, #[[{1, 2}]]] & /@ a)],
Infinity]]
...
13
This is my implementation using Graphics primitives and rules. Here's the final result; the implementation details and edge cases follow.
1. General approach
First, we start with a single square and build up a test grid:
square = Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}];
grid = Graphics[{EdgeForm[Black], FaceForm[None],
Table[Transpose@First@square ...
12
Hm, I am late for the party but anyway here is my entry. This distmesh port works in 2D and 3D (though this has issues I should say) and does not need external code like qhull. It also has a quality control / max steps termination and boundary points to be included can be given. Note, however, this is a prototype code and it has issues. A word about distmesh ...
12
Not sure about the creation of a "smooth" surface. But from Mma help, you may create a convex hull in 3D by using TetGenConvexHull
Needs["TetGenLink`"]
data3D = RandomReal[{0, 1}, {100, 3}];
Graphics3D[Point[data3D]];
surface = TetGenConvexHull[data3D];
(* TetGenConvexHull was changed sometime between 8.0.0 and 8.0.4.
Uncomment the following line only if ...
11
You could use the (undocumented) option Method -> {"TransparentPolygonMesh" -> True} for this, e.g.
Show[Graphics[Point[{p1, p2}]],
RegionPlot[{d[{x, y}, p1, M1] < d[{x, y}, p2, M2],
d[{x, y}, p1, M1] > d[{x, y}, p2, M2]}, {x, -4, 4}, {y, -4, 4}],
Method -> {"TransparentPolygonMesh" -> True}]
which produce
11
I just followed examples in TetGenLink documentation:
Needs["TetGenLink`"]
data3D =
N@Flatten[Table[{r Cos[phi], r Sin[phi], z}, {phi, 0, 2 Pi, .5},
{z, -4, 4, .5}, {r, .2, 1, .4}], 2];
in = TetGenCreate[];
TetGenSetPoints[in, data3D];
out = TetGenTetrahedralize[in, ""];
coords = TetGenGetPoints[out];
meshElements = TetGenGetElements[out];
...
10
First, you can generate your random points like so:
SeedRandom[1];
pts = RandomReal[{0, 12}, {100, 2}];
The DelaunayTriangulation command returns an adjacency list representation of the triangulation.
Needs["ComputationalGeometry`"];
dt = DelaunayTriangulation[pts];
dt // Column
This says that the first point should be connected to the 2nd, the 24th, ...
10
Here's a possible approach.
First use TetGen to tetrahedralize the data:
Needs["TetGenLink`"]
{pts, tetrahedra} = TetGenDelaunay[data3D];
Next define a function to compute the radius of the circumsphere of a tetrahedron (formula from Wikipedia)
csr[{aa_, bb_, cc_, dd_}] :=
With[{a = aa - dd, b = bb - dd, c = cc - dd},
Norm[a.a Cross[b, c] + b.b ...
10
As pointed out in the comments, there's really no mathematical definition of a concave hull.
Of course, just because there's no mathematical definition does not preclude coming up with something that sort of works. I can think of two ways to do this:
Easy Way, Not General
Your data roughly has axial symmetry parallel to the x-axis. Moreover, all of your ...
9
Your second data set has intersecting facets. There is no way TetGen can tetrahedralize that.
Needs["TetGenLink`"];
res = TetGenDetectIntersectingFacets[data02,
Partition[polysurface2, 1]];
Graphics3D[GraphicsComplex[res[[1]], Polygon[res[[2]]]]]
So the solution is to fix the data set. I have to see about how to improve the assertion error. The ...
9
Table[drawtriangulation[mesh @@ example, First@example,
AspectRatio -> Automatic],
{example, {circle, circle34, ellipseeye}}] // GraphicsRow
Calculating specifications for these examples:
(* distance function, bounding box, fixed points,
number of initial points, max iterations, min triangle quality *)
circle = {Sqrt[#1^2 + #2^2] - 1. &,
...
8
first part..i had lying around..
poly = Random[Real, {1, 2}] {Cos[#], Sin[#]} & /@ Sort[Table[Random[Real, {0, 2 Pi}], {5}]]
isLeft[P2_, {P0_, P1_}] := -Sign@Det@{P2 - P0, P1 - P0};
pinpoly[p_, poly_] := Module[{ed},(*winding rule*)
ed = Partition[Append[poly, poly[[1]]], {2}, 1];
Count[ed,pr_ /; (pr[[1, 2]] <= p[[2]] < pr[[2, 2]] ...
8
Here is an (imperfect) starting point for how to use ListSurfacePlot3D with this example. It needs manual refinement, but I only have time for this quick test:
pts = Import["http://dl.dropbox.com/u/68983831/tube01.vtk",
"VertexData"];
Show[Map[ListSurfacePlot3D[#] &, Partition[pts, 300]]]
The idea is to break the over 6000 points in your shape ...
8
You can add the mesh specific to the x and y coordinates of your data with Mesh -> {First /@ bData, #[[2]] & /@ bData}:
p1 = ListPointPlot3D[bData, PlotStyle -> PointSize[Large]]
p2 = ListPlot3D[bData, MeshStyle -> Red, PlotStyle -> None,
Mesh -> {First /@ bData, #[[2]] & /@ bData},
InterpolationOrder -> ...
8
As you state, TetGenDelaunay is for a tetrahedralization of the 3D space of the input data, and you'd then need to extract the surface triangulation. So for TetGenDelaunay there is no way around the tetrahedralization. (But I wonder if this is not also the case for DelaunayTri) TetGen is quite efficient, so maybe this is still an option. Perhaps, depending ...
7
This will do
densPlot =
DensityPlot[
4 Sin[2 Pi x] Cos[1.5 Pi y] (1 - x^2) (1 - y) y, {x, -1, 1}, {y, 0,
1}, MeshStyle -> Thick, Mesh -> All];
vertexCoordinates = densPlot[[1, 1]];
length = Length[vertexCoordinates];
graphReadyConnections =
DeleteDuplicates@
Flatten[
Cases[#,
List[x_, y_, z_] :> {Sort[x ...
7
At OP's behest:
The easiest approach to see the mesh lines is to remove the EdgeForm[] instruction that causes them not to appear. For instance,
DeleteCases[Import["ExampleData/wrench.obj.gz"], _EdgeForm, ∞]
As SEngstrom suggests, you can also use a replacement rule. If, for instance, you want a thick gray mesh, here's what you can do:
...
6
The procedure I suggested for your other "concave hull" question seems to work reasonably well here, simultaneously isolating the clusters and creating the surfaces.
Needs["TetGenLink`"];
{pts,tetrahedra}=TetGenDelaunay[data3D];
csr[{aa_,bb_,cc_,dd_}]:=With[{a=aa-dd,b=bb-dd,c=cc-dd},
Norm[a.a Cross[b,c]+b.b Cross[c,a]+c.c Cross[a,b]]/(2Norm[a.Cross[b,c]])];
...
6
As I said before, there really isn't such a thing as a concave hull. What you want to do is plot your clusters here.
The first problem involves a machine vision problem known as 3D segmentation. Mathematica doesn't have any tools out of the box to do this, as far as I know.
One way is to guess how many "clusters" are in your data, although that's hard to ...
6
With your data you could try to specify the divisions of the Mesh to match your x and y coordinates:
p1 = ListPointPlot3D[bData, PlotStyle -> PointSize[Large]];
p2 = ListPlot3D[bData, MeshStyle -> Red, PlotStyle -> None,
Mesh -> {Union[bData[[All, 1]]], Union[bData[[All, 2]]]},
InterpolationOrder -> 10, PlotRange -> All];
Show[p1,p2]
...
6
This doesn't really answer the question, but might help you with your investigations...
By setting the system option "VisualizationOptions" -> {"Verbose" -> True} you get all sorts of information printed about the plotting process. The code below intersperses that output with the actual sampled points (shown as ListPlots), showing the initial sampling ...
6
It seems you are asking for the Delaunay triangulation.
There's a function for this in the Computational Geometry package, which Mark described.
Another, usually much faster option is using ListDensityPlot:
ldp = ListDensityPlot[ArrayPad[p0, {0, {0, 1}}], Mesh -> All,
ColorFunction -> (White &)]
You can extract the polygons from this ...
6
What about this:
Import["ExampleData/wrench.obj.gz", "PolygonObjects"] // Graphics3D
You can use the FaceForm[None] trick as shown by @J.M. here just as well if you only want the wireframe looks.
5
You could put caps on your cylinder and control the mesh with PlotPoints and MaxRecursion:
Show[
ParametricPlot3D[{r Cos[phi], r Sin[phi], 4}, {phi, 0, 2 Pi}, {r, 0, 1},
Mesh -> All, PlotPoints -> {25, 4}, MaxRecursion -> 0],
ParametricPlot3D[{r Cos[phi], r Sin[phi], -4}, {phi, 0, 2 Pi}, {r, 0, 1},
Mesh -> All, PlotPoints -> {25, 4}, ...
5
If you don't mind using undocumented functions, you can do it like this:
Graphics`Mesh`MeshInit[];
mesh = DensityPlot[4 Sin[2 Pi x] Cos[1.5 Pi y] (1 - x^2) (1 - y) y, {x, -1, 1}, {y, 0, 1},
Method -> {"ReturnMeshObject" -> True}];
Graph[mesh["Edges"], VertexCoordinates -> mesh["Coordinates"],
VertexShapeFunction -> (Point[#] &)]
4
As far as I know, there is no built-in function to do this. However, what you can do is a heavy abuse of Part to extract the points from a Plot object:
g = Plot[Sin[x], {x, 0, 2 Pi}]
The InputForm, i.e. how Mathematica sees this picture internally, looks like like this:
Graphics[{{{}, {}, {Hue[0.67, 0.6, 0.6], Line[{{1.2*^-7, 1.2*^-7}, [long list ...
4
I know you really wanted dashed lines, but if you just wanted some contrast for the 'hidden' lines:
SphericalPlot3D[{1, 1}, {ϴ, 0, Pi}, {Φ, 0, 2 Pi},
PlotStyle -> {{FaceForm[None], EdgeForm[None]},
{Opacity[0.9], FaceForm[White], EdgeForm[None]}},
Mesh -> 20,
Boxed -> False,
Axes -> None,
Lighting -> ...
4
You could join two separate hemispheres, each with its own MeshStyle.
You may have to tweak the ViewPoint or the angles of the plot in order to hide the back mesh from view. In the case below, I simply moved the ViewPoint to {1, -10, 0}.
h1 = ParametricPlot3D[{Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]}, {u, 0, Pi}, {v, 0, Pi},
MeshStyle -> Dashed, PlotRange ...
Only top voted, non community-wiki answers of a minimum length are eligible

