Tag Info

New answers tagged

4

Here are a few more thoughts: When you run this through DiscretizeGraphics you get a message about degenerate cells: DiscretizeGraphics[Polygon[data]]; MeshRegion::dgcell: "The cell Polygon[{39,40,39,41}] is degenerate." As noted scaling helps: mr = DiscretizeGraphics[Polygon[data.DiagonalMatrix[{1, 1000}]]] You can use the Finite Element mesher and ...


6

The polygon is very thin. If we scale the points so that the polygon is of good proportions Area works. GraphicsRow[{ Graphics[{Red, Polygon[pts]}], Graphics[{Red, Polygon[pts.DiagonalMatrix[{1, 1000}]]}]}, Frame -> All] Area[Polygon[pts.DiagonalMatrix[{1, 1000}]]]/1000 (* 2018.48 *) One might suppose that round-off error causes the failure ...


3

Maybe this can get you started. It assumes the point {x, y} is on the boudary and that the region is described by inequalities involving either <= or >= that are returned by RegionMember. normal[reg_] := Piecewise /@ Transpose[ Thread[{Normalize@D[First@#, {{x, y}}], # /. LessEqual -> Equal}] & /@ Cases[ Simplify[ ...


0

I'm not sure it will be useful, but one approach is to flip the problem on its head by imagining a ball about the region r, and finding the nearest points from the ball to the region... these are perpendiculars, though you might need to search them to find a specific one: r = Disk[{0, 0}, {2, 1}]; pts = Table[3 {Cos[k 2 \[Pi]/16], Sin[k 2 \[Pi]/16]}, {k, ...


6

---EDIT--- @MichaelE2 is right in that it isn't the overlap (or at least not just the overlap) that is to blame. However, it's not just the scaling of the fast dimension either. You can see that if you resample the data by adding another point. Then Area calculates this just fine! data2[n_] := Transpose[ArrayResample[#, n] & /@ Transpose[data]]; so ...


3

$Version "10.0 for Mac OS X x86 (64-bit) (September 10, 2014)" Clear[x1, x2]; g1[x1_, x2_] := x1^4 - x2 + 1; g2[x1_, x2_] := -x1^3 + x2 - 1; f[x1_, x2_] := Which[ g1[x1, x2] <= 0 && g2[x1, x2] <= 0, (x1 + 1)^2 + (x2 + 1)^2]; Instead of increasing the number of PlotPoints with RegionPlot, use ImplicitRegion RegionPlot[ ...


3

I finally found a solution: mask = (* As seen above, copied from masking tool as a "Image *) pos = Position[mask // ImageData, 1]; spectra = Extract[img, pos];


1

You can sort of achieve it with RegionDiscretize and BoundaryMesh regn = BoundaryMesh@DiscretizeRegion@ RegionDifference[Rectangle[{-2, -2}, {2, 2}], Disk[{0, 0}, 1]] Show[regn, Graphics@Line[{{0, 0}, {3, 1}}]] MeshRegions (what DiscretizeRegion generates) have many styling options.



Top 50 recent answers are included