Tag Info

New answers tagged

2

If we want all pairs of indices of vertices connected by a line segment, then MeshCells will return the list in the form {Line[{i, j}]..}. foo = DiscretizeRegion[Disk[], MaxCellMeasure -> 0.1]; bobbie = MeshCells[foo, 1][[All, 1]] (* {{9, 10}, {10, 23}, {23, 9}, {35, 8}, {8, 9}, {9, 35}, {29, 20}, {20, 16}, {16, 29}, {6, 7}, {7, 20}, {20, 6}, {36, ...


0

Thanks to Guess Who It is and user21 for their help in the comments of the original question, if they want to submit the same answer fully I'll remove this no problems and vote theirs up. Defining a region: foo = DiscretizeRegion[Disk[], MaxCellMeasure -> 0.1] Then the connectivity of the polygon data exists if the output of foo is inspected. (Guess ...


9

NMinimize does not work with ElementMesh (which is not RegionQ) directly. Perhaps it could, but for now I would suggest converting the element mesh to a region: NMinimize[x^2 + y^2, {x, y} \[Element] MeshRegion[disk]]


0

I was a bit confused about your definition of "connectivity" and which points are and are not to be selected, but I hope I understood what you wanted. AllConnections=Table[DeleteCases[Flatten[Select[MeshCells[foo, 1][[All, 1]], #[[1]] == n || #[[2]] == n &]],n], {n, Length[MeshCells[foo, 0]]}]; ...


3

Needs["NDSolve`FEM`"] numRings = 10; numSectors = 40; points = Flatten[ Table[ r {Cos[ϕ], Sin[ϕ]}, {r, 1, numRings}, {ϕ, 0, 2 π - 2 π/numSectors, 2 π/numSectors} ], 1 ]; triangles = Flatten[ Table[ { { numSectors (i + 1) + j, numSectors i + Mod[1 + j, numSectors, 1], ...


4

Let b1, b2 map the unit circle to the inner, outer boundaries respectively. You might need to handle a list of points with Map (e.g., b1 /@ bdy) depending on b1 and b2. Then here is a simple way: Needs["NDSolve`FEM`"] Clear[b1, b2]; n = 100; bdy = Table[{Cos[t], Sin[t]}, {t, 0., 2 Pi - 2 Pi/(2 n), 2 Pi/(2 n)}]; hole = {0., 0.}; b1[pts_?MatrixQ | ...


4

DiscretizeRegion will work in place of ToElementMesh: Jet0[pts_: {{1, 0}, {1.8, 1.8}, {0, 2}}] := Module[{xu, yu, n, m, knots, fx, fy, pr, t, r}, {xu, yu} = Transpose[pts]; n = 2; m = Length[pts]; knots = {ConstantArray[0, n + 1], Range[m - n - 1]/(m - n), ConstantArray[1, n + 1]} // Flatten; fx[t_] = xu.Table[BSplineBasis[{n, knots}, i - 1, ...


5

There is a workaround involving Rationalize. Jet0[pts0_: {{1, 0}, {1.8, 1.8}, {0, 2}}] := Module[{xu, yu, n, m, knots, fx, fy, pr, mesh, t, r}, pts=Rationalize[pts0,0.001]; {xu, yu} = Transpose[pts]; n = 2; m = Length[pts]; knots = {ConstantArray[0, n + 1], Range[m - n - 1]/(m - n), ConstantArray[1, n + 1]} // Flatten; fx[t_] = ...


5

The best way (as pointed out by @Guesswhoitis.) is to convert splines into implicit functions. The real issue you are having is that you'd need a second order mesh to get a decent solution. Note that DiscretizeGraphics and DiscretizeRegion create first order meshes. So you'd need to use ToElementMesh. We also would like to have a finer boundary resolution, ...


2

What you want is the 2D alpha shape to try to get close to the outline you seek. Of course, it's no longer a Delaunay triangulation since you're deleting certain polygons from the DelaunayMesh. We'll adopt my answer from this post. Here it is for a 2D point set: alphaShapes2D[points_, crit_] := Module[{alphacriteria, del = Quiet @ DelaunayMesh @ points, ...


5

If what you want is a nice smooth surface of the outer boundary, then in Mathematica 10.2 you can do the following: data3D = RandomReal[{0, 1}, {100, 3}]; (* generate some random point *) cvx = ConvexHullMesh[data3D] (* get the outer boundary *) Now we can Discretize the surface and smooth it in one go: smooth = DiscretizeRegion[cvx, ...


2

After thinking about it, i solved the problem by considering: region = RegionBoundary[ BoundaryDiscretizeRegion[Ellipsoid[{0, 0, 0}, {1, 0.125, 0.125}], MaxCellMeasure -> 0.1]] in this only the surface is discretized and the mesh quality can be specified by MaxCellMeasure.


4

If I understand the question correctly, one possibility is to decompose the surface of the Tetrahedron into four triangles, intersect each with Container, compute the Area of the resulting planar objects, and sum them. Area[RegionIntersection[Polygon[#], Container]] & /@ Subsets[{{0, 2, 0}, {0, -2, 0}, {-2, 0, 0}, {0, 0, 2.5}}, {3}] // Total (* ...


5

The solution or rather "fix" to the problem seems to be to raise the MaxPlotPoints: data = RandomReal[{0, 1}, {21, 500}]; MatrixPlot[ data, AspectRatio -> Full, FrameTicks -> Automatic, ColorFunction -> (Hue[1 - #] &), ColorFunctionScaling -> True, MeshStyle -> Blue, Mesh -> {Table[j, {j, 0, 25, 5}], ...


5

This started out as a long comment, but in the meantime I think I found the solution to this problem which is clearly a bug in MatrixPlot. My initial analysis follows and the conclusion and a solution are at the bottom. First, this is not typical to 10.1. I see identical behavior in versions 8 and 9. Second, your example can be simplified to reduce the ...


2

Working with GraphicsComplex retains a degree of flexibility. For instance, Graphics3D[GraphicsComplex[p[[1, 1]], Line[Rest@Cases[p, Line[z__] :> z, Infinity]]]] gives the Mesh in 3D. (Rest@ deletes the perimeter of the surface.) If, instead, a plot of the points in 3D is desired, use Graphics3D[GraphicsComplex[p[[1, 1]], ...


2

Expanding @Guess comment: p1 = Join @@ Cases[Normal@p, Line[x1__] :> x1, Infinity]; ListPlot[Most /@ p1] p1 = Join @@ Cases[Normal@p, Line[x1__] :> {RGBColor @@ RandomReal[{0, 1}, 3], Line[Most /@ x1]}, Infinity]; Graphics[p1, AspectRatio -> 1/GoldenRatio]



Top 50 recent answers are included