Tag Info

New answers tagged

2

I would work purely on the list of points. You have the radius r, so you can easily identify connected regions with points = {{27, 38}, {31, 50}, {33, 56}, {34, 38}, {39, 51}, {39, 63}, {40, 31}, {42, 45}, {42, 55}, {47, 27}, {47, 50}, {48, 35}, {48, 65}, {49, 43}, {52, 57}, {54, 50}}; data = ReplacePart[ConstantArray[0., {96, 145}], points -> ...


3

Here is a graph based solution. However the result (the pixels) will be dependent on resolution, and this solution currently uses the lowest resolution possible. withinRange[range_][pt1_, pt2_] := Norm[pt1 - pt2] <= 2 range adjacencyMatrix = Boole@Outer[withinRange[3.5], points, points, 1] -IdentityMatrix@Length@points; Some work may be saved by only ...


8

Yes, this is a bug in the more general function RegionMeasure. I knew there were some edge cases in the handling of inexact numberics, but I was unaware of such a simple example. I will forward this bug internally. Workarounds include using the parametric (2-argument) form of ArcLength, and using DiscretizeRegion to preprocess regions before sending them ...


1

It seems to me there are a few sorts of answers to the question, like a numeric visualization, e.g. a RegionPlot a system of algebraic conditions, a geometric one, i.e. the resulting polygon(s) Here is a variation on halirutan's use of the geometric computation functionality: reg = RegionIntersection[ Polygon[{{0, 0}, {10, 0}, {10, 10}, {0, 10}}], ...


5

I guess a pretty easy approach is to use HalfPlane with your two points that define your line. RegionDifference should do the rest. RegionDifference[ Polygon[{{0, 0}, {10, 0}, {10, 10}, {0, 10}}], HalfPlane[{{1, 0}, {3, 7}}, {1, 1}]]; RegionPlot[%]


1

in MMA v10 (although it is slow) you can use: Clear[r]; r[point1_, point2_] := ImplicitRegion[{x, y} \[Element] Polygon[{{0, 0}, {10, 0}, {10, 10}, {0, 10}}] && y >= point2[[2]] + (point2[[2]] - point1[[2]])/( point2[[1]] - point1[[1]]) (x - point2[[1]]), {x, y}] RegionPlot[r[{2, 2}, {6, 3}]]


1

This is just an extended comment. The corners that you used to define the Cuboid do not define a valid region. While Cuboid[{2, -2, -1}, {-2, 2, 3}] and Cuboid[{-2, -2, -1}, {2, 2, 3}] fill the same space, Mathematica only considers the second Cuboid to be a valid region. RegionQ /@ { Cuboid[{2, -2, -1}, {-2, 2, 3}], Cuboid[{-2, -2, -1}, {2, 2, 3}]} ...


2

p2 = Animate[Show[{ RegionPlot3D[ And[-2 < x < 2, -2 < y < 2, -1 < z < 3, z - t y - t x < 0], {x, -4, 4}, {y, -4, 4}, {z, -4, 4} ], ContourPlot3D[{z - t y - t x == 0}, {x, -3, 3}, {y, -3, 3}, {z, -7, 7}, MeshFunctions -> {Function[{x, y, z, f}, x^2 + y^2 - r^2 - z + t y + t x]}, Mesh ...


0

To get finer triangles the option MaxCellMeasure is available, only it does nothing when used. This is fixed in 10.0.2. on windows 7, 64 bit


5

edges = coords /. Line[{a_, b_}] :> UndirectedEdge[a, b]; g = Graph[edges]; starts = VertexList[g, {_, 0}]; ends = VertexList[g, {_, 4}]; Intersection[Join @@ ConnectedComponents[g, starts], ends] != {} (*True*) And we can show all of them ... g = Graph[edges]; g1 = SetProperty[g, VertexCoordinates -> VertexList@g]; paths = ...


1

So in fact, this is a graph search problem, Right? The normal approaches is to use Depth-First-Search(DFS) or Breadth-First-Search(BFS) to test connected relation of two points. For example, if you want to test whether coordinate (3,0) is connected to coordinate (2, 4), you can just use DFS or BFS to do the test. I think the trick point in your problem ...


1

Well, since you bragged about computing power... Clear@findIntersections; findIntersections[polyGroup__] := Module[{reg}, reg = RegionIntersection[ Sequence @@ DiscretizeRegion[#, PerformanceGoal -> "Quality", Method -> "DiscretizeGraphics", AccuracyGoal -> 10, PrecisionGoal -> 10] & /@ polygons[[polyGroup]]]; ...


3

For a version 9 solution, consider two line segments, the first between $\{x_1,y_1\}$ and $\{x_2,y_2\}$, the second between $\{u_1,v_1\}$ and $\{u_2,v_2\}$. Parameterize points on the two segments with $\{x_1,y_1\}+s~ (\{x_2,y_2\}-\{x_1,y_1\})$ and $\{u_1,v_1\}+t~(\{u_2,v_2\}-\{u_1,v_1\})$, where the parameters $s$ and $t$ must lie between 0 and 1, ...


8

As you are using v9, I would suggest using the undocumented function - Graphics`Mesh`IntersectQ which does exactly what you want: plist = {Line[{{20, 10}, {20, 0}}], Polygon[list]}; Graphics`Mesh`IntersectQ[plist] Graphics[MapThread[{##} &, {{Red, Blue}, plist}]] (* False *) which is also in v10.


5

Another partial (see caveat) V10-based answer using Solve. The nice feature here is that exact solutions are returned (provided the input is exact, too). Caveat: Will only return intersection points on the border of the polygon. Plus, slow. I took the liberty to change the initial line into an InfiniteLine to add some spice. Essentially this solves for ...


5

A "solution" using v10 would be: RegionQ@DiscretizeRegion@RegionIntersection[r1, r2]. For example: r1 = Line[{{0, 10}, {20, 0}}]; r2 = Polygon[{{4.4, 14}, {6.7, 15.25}, {6.9, 12.8}, {9.5, 14.9}, {13.2, 11.9}, {10.3, 12.3}, {6.8, 9.5}, {13.3, 7.7}, {0.6,1.1}, {1.3, 2.4}, {2.45, 4.7}}]; g = Show[Graphics[{r1, r2}]]; ri = ...


7

In v10 this is a one-liner: RegionDimension@RegionIntersection[Line[{{0, 10}, {20, 0}}], Polygon[list]]] > -∞ because an empty region has dimension $-\infty$. I do wish there was a NonemptyQ predicate one could use directly, though.



Top 50 recent answers are included