Tag Info

New answers tagged

3

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 ...


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

As mentioned by user21 in the comments, this bug has been fixed as of version 10.1.0. Table[(RegionUnion[Disk[{0, 0}, 1, {0, Pi}], Disk[{1/2, 0}, 1/2]] // RegionDifference[#,RegionUnion[Disk[{1/2, 0}, 1/6], Disk[{-1/2, 0}, 1/2]]] &) // DiscretizeRegion // AbsoluteTiming // First, {100}] // Mean (* 0.142127 *)


2

This works without any error messages: TEST = Compile[{{x, _Real}, {y, _Real}, {z, _Real}}, -x y z]; TESTfn[x_?NumericQ, y_?NumericQ, z_?NumericQ] := TEST[x, y, z]; RegionPlot3D[ImplicitRegion[TESTfn[x, y, z] > 0, {{x, -5, 5}, {y, -5, 5}, {z, -5, 5}}]] The second function, TESTfn, is necessary to ensure you only pass numeric (and not symbolic) ...


3

Until this is fixed in a future version, here is a workaround for now: Unprotect[RegionBoundary]; RegionBoundary /: Area @ RegionBoundary @ SphericalShell[c_, {ri_, r_}] := Area @ Sphere[c, r] + Area @ Sphere[c, ri]; RegionBoundary /: Area @ RegionBoundary @ CapsuleShape[{v1_, v2_}, r_] := 2 π r (2 r + ...


0

As recommended in comment by @ilian acap = Area@ RegionBoundary@DiscretizeRegion@CapsuleShape[{{-1, 0, 0}, {1, 0, 0}}, 1] 25.0897 Round[acap/Pi, 1/10]*Pi 8 Pi ashell = Area@ RegionBoundary@DiscretizeRegion@SphericalShell[{0, 0, 0}, {3, 4}] 313.472 Round[ashell/Pi]*Pi 100 Pi


5

Graphics (and Graphics3D) accept graphics primitives as input. Version 10 introduced a number of special (or basic) geometric regions which serve as both regions and graphics primitives, so they can be given directly to Graphics (at least the 2D and 3D cases), for example Graphics[Disk[]]. When it comes to derived regions, sometimes they directly correspond ...


4

As ilian pointed out in a comment, you are not limited to DiscretizeRegion for visualizing a region. There is also RegionPlot, which may be more to your liking. Comapare r = RegionUnion[Disk[{0, 0}, 1], Disk[{2, 0}, 1]]; DiscretizeRegion[r] with RegionPlot[r, AspectRatio -> Automatic]


6

The region is a union of cuboids, which in FEM-talk is a HexahedronElement. We can just take all the coordinate boundaries, divide space into cuboids according to the coordinates, and select the ones whose mid point lies in the region defined by the OP's expression, which I store in exp. Needs["NDSolve`FEM`"]; exp = (RegionMember[Cuboid[{0, 0, -6.5}, ...


3

BoundaryDiscretizeRegion can handle a variant of your ImplicitRegion just fine. reg = ImplicitRegion[ (RegionMember[Cuboid[{0, 0, -6.5}, {110, 90, 0.}], {x, y, z}] || Or @@ (RegionMember[#, {x, y, z}] & /@ GenerateCubes[10, 0.2]) || Or @@ (RegionMember[#, {x, y, z}] & /@ GenerateCubes[30, 0.1])) || Or @@ (RegionMember[#, {x, y, ...


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 (* ...


7

The Raspberry Pi build does not include certain components. In particular, TetGenLink and TriangleLink are not available which will affect region discretization (and PDE solving over regions etc.)


3

Solution with NIntegrate NIntegrate[f[X[u, v]] Norm[Cross[D[X[u, v], u], D[X[u, v], v]]], {u, -π/2, π/2}, {v, 0, π}] (* 19.8097 *) An alternative approach to the problem is s = ImplicitRegion[{x^2/2 + y^2/3 + z^2/2 == 1 && y > 0}, {x, y, z}]; Chop[NIntegrate[x^2 + z^2, {x, y, z} ∈ s], 10^-7] which, of course, yields the same answer. Added: ...


1

If you have only two regions $A_1$ and $A_2$, and every point in their sum/product can be attained as the sum/product of points on the boundaries of $A_1$ and $A_2$, then you could do something like this: ParametricPlot[ Through@{Re, Im}@((1 + Exp[I t1]) (1 + Exp[I t2])), {t1, -Pi, Pi}, {t2, -Pi, Pi}, Mesh -> 7]


8

RegionMeasure chooses a method which is slow when exact non-rational coefficients are present. I will correct this for a future version. Thanks for pointing it out. In Mathematica 10 the example works fast with approximate coefficients. In[1]:= Timing@RegionMeasure@N@ RegionIntersection[ Tetrahedron[{{0, 0, Sqrt[3/2]}, {2/Sqrt[3], 0, ...


9

Good news! Version 10.2 of Mathematica has this built-in with the function RandomPoint[]. From the documentation: RandomPoint can generate random points for any RegionQ region that is also ConstantRegionQ. RandomPoint will generate points uniformly in the region reg. The first example given is a simple disk, but there are a whole host of ...


6

You can use the undocumented ReturnMeshObject method like @Simon Woods used here to get ListSurfacePlot3D to do the smoothing for you. With this option added, it returns a GraphicsComplex ready to be used by DiscretizeGraphics. Graphics`Mesh`MeshInit[]; mc = MeshCoordinates[surface]; extractedmesh = DiscretizeGraphics[ First@ListSurfacePlot3D[mc, ...


1

The root cause of the problem reported in the question was a bad formula. This led to a call to ArcCos that, with some arguments, produced a complex number as a result. When this value was given to any of the Region functions, an error resulted. The only way that I could find to debug the problem was traditional: isolate a failing case, working step by step ...


1

Here's a way that takes advantage of the undocumented PlotPoints form that allows specific sample points to be included. See Specific initial sample points for 3D plots for more. Test function I'll construct a function with five maxima of the same height. SeedRandom[0]; ncp = 5; cp = RandomReal[{0, 2}, {ncp, 2}]; f[x_, y_] = Simplify[ (* set up with ...


0

Your original approach can work if you exploit RegionPlot as an alternative to DiscretizeRegion. With RegionPlot, the resulting Graphics must be deconstructed to find the corresponding region. However, you can use the PlotPoints option to offer some help finding small regions. I thought the Method->"RegionPlot" option of DiscretizeRegion might be used to ...


4

ImplicitRegion seems to work fine: ir = With[{b = 2, h = 2}, ImplicitRegion[{(x)^2 + (y - b)^2 > h^2 + b^2 && (x)^2 + (y - b - h)^2 > h^2 + b^2 && (x - h)^2 + (y - 2 b - h)^2 > h^2 + b^2 && (x - h - b)^2 + (y - 2 b - h)^2 > h^2 + b^2 && (x - 2 h - b)^2 + (y - b - h)^2 > h^2 + b^2 ...



Top 50 recent answers are included