Hot answers tagged

11

If you use ToElementMesh, you can capture the features of the rectangle much better. (*Import required FEM package*) Needs["NDSolve`FEM`"]; With[{outer = Disk[], inner = Rectangle[{-1 / 2, -1 / 2}, {1 / 2, 1 / 2}]}, (mesh = ToElementMesh[RegionDifference[ outer, inner]])["Wireframe"] ] If you use the FEM mesh ...


6

For a given j,We can use Hyperplane[points[[j]], points[[j]]] to represent the plane which tangent to the unit sphere at point points[[j]]. Then we use another n-1 HalfSpace to cut such plane and get one of such face. n = 30; points = RandomPoint[Sphere[], n]; faces = Table[ RegionIntersection[Hyperplane[points[[j]], points[[j]]], Sequence @@ ...


5

lst = Table[{dj, di}, {dj, 0, 1, 0.2}, {di, 0, 1, 0.2}] (* {{{0., 0.}, {0., 0.2}, {0., 0.4}, ..., {1., 0.8}, {1., 1.}}} *) Flatten at level 1 to keep {dj,di} points and remove other dimensions lst2 = Flatten[lst, 1] (* {{0., 0.}, {0., 0.2}, {0., 0.4}, ..., {1., 0.8}, {1., 1.}} *) Use Select to perform a test on each point Select[lst2, #[[2]] >= ...


4

Using the two-argument form of DiscretizeRegion we get three points: MeshCoordinates[DiscretizeRegion[ri, CoordinateBounds[ri]]] {{2.95674, 3.87023}, {3.20154, 4.60463}, {3.42285, 5.26855}} FWIW, we can also use MeshPrimitives to get the three Points: MeshPrimitives[DiscretizeRegion@ri, 0] {Point[{2.95674, 3.87023}], Point[{3.20154, 4.60463}], Point[{3....


3

We can also use RegionMember and Solve or Reduce to get the points. sol = Solve[RegionMember[ri, {x, y}]] {x, y} /. sol // N {{2.95674, 3.87023}, {3.20154, 4.60463}, {3.42285, 5.26855}}


3

Region is a rather quick and dirty plotting routine. More elaborate is RegionPlot: n = 30; SeedRandom[1]; points = RandomPoint[Sphere[], n]; p = ImplicitRegion[ Table[points[[i]].{x, y, z} <= 1, {i, 1, n}], {x, y, z}]; d = 1.3; RegionPlot3D[{x, y, z} \[Element] p, {x, -d, d}, {y, -d, d}, {z, -d, d}, PlotPoints -> 20]


2

Select is probably the most idiomatic way to do this, but just for fun, here are some other ways to do it by using Tuples to generate the list of pairs (avoiding use of the Flatten) and defining a function that returns Nothing to create an "empty" entry in the list that gets removed (avoiding the use of Select). There's no good reason to do this, ...


2

You can also use Select to modify the iterator list for di: selectIterators[x_] := Select[2 - Sqrt[2] Sqrt[(1 - x) (2 - x)] - x <= # <= x &]@*Range Example: Join @@ Table[{dj, di}, {dj, 0, 1, .2}, {di, selectIterators[dj][0, 1, .2]}] {{0., 0.}, {0.2, 0.2}, {0.4, 0.4}, {0.6, 0.4}, {0.6, 0.6}, {0.8, 0.6}, {0.8, 0.8}, {1., 1.}}


1

To set the 2d graphics default (here, to Red), use SetOptions[Graphics, BaseStyle -> Red]; Then, Graphics[Triangle[]] Subsequent commands, like Graphics[Circle[]], also yield Red images by default. Many other default options also can be set in the same way. Remove the ; from the first command to see them. On the other hand, if you wish this default to ...


Only top voted, non community-wiki answers of a minimum length are eligible