Tag Info

Hot answers tagged

20

You are combining the images in the form Show[Graphics[simplePrimitives], complicatedRegionPlot] The options in the resulting figure are inherited from the first term, namely Graphics[simplePrimitives]. This does not include the "TransparentPolygonMesh" -> True generated by RegionPlot. You see the mesh as a result. If you combine things as follows: ...


15

Here's my go at it. This tells you if two line segments intersect (unless they lie on the same line, in which case it fails horribly): ClearAll[segmentsIntersect]; segmentsIntersect[{a_, b_}, {p_, q_}] := Module[{s, t, soln}, soln = NSolve[a + t (b - a) == p + s (q - p), {s, t}]; If[Length@soln == 0, False, (0 <= s <= 1 && 0 <= t ...


15

Mathematica has lots of Graphics primitives for you to work with, as well as directives such as Thick, Dashed, Red, etc. I'll use Arrow below. You can specify the value of the GridLines option as a function. Using GridLines -> Range will give lines on a 1:1 grid starting from the extreme lower left of the graphic, as set with PlotRange or determined ...


13

It might be easier to use TriangularSurfacePlot3D to find the Delaunay triangulation of the points. For example, Needs["ComputationalGeometry`"]; triangles[points_] := Module[{pl}, pl = TriangularSurfacePlot[ArrayPad[points, {{0, 0}, {0, 1}}]]; Cases[pl, Polygon[a_] :> Flatten[(Position[points, #[[{1, 2}]]] & /@ a)], Infinity]] ...


12

Table[drawtriangulation[mesh @@ example, First@example, AspectRatio -> Automatic], {example, {circle, circle34, ellipseeye}}] // GraphicsRow Calculating specifications for these examples: (* distance function, bounding box, fixed points, number of initial points, max iterations, min triangle quality *) circle = {Sqrt[#1^2 + #2^2] - 1. &, ...


12

This is my implementation using Graphics primitives and rules. Here's the final result; the implementation details and edge cases follow. 1. General approach First, we start with a single square and build up a test grid: square = Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}]; grid = Graphics[{EdgeForm[Black], FaceForm[None], Table[Transpose@First@square ...


12

You could use the (undocumented) option Method -> {"TransparentPolygonMesh" -> True} for this, e.g. Show[Graphics[Point[{p1, p2}]], RegionPlot[{d[{x, y}, p1, M1] < d[{x, y}, p2, M2], d[{x, y}, p1, M1] > d[{x, y}, p2, M2]}, {x, -4, 4}, {y, -4, 4}], Method -> {"TransparentPolygonMesh" -> True}] which produce


11

Not sure about the creation of a "smooth" surface. But from Mma help, you may create a convex hull in 3D by using TetGenConvexHull Needs["TetGenLink`"] data3D = RandomReal[{0, 1}, {100, 3}]; Graphics3D[Point[data3D]]; surface = TetGenConvexHull[data3D]; (* TetGenConvexHull was changed sometime between 8.0.0 and 8.0.4. Uncomment the following line only if ...


11

I just followed examples in TetGenLink documentation: Needs["TetGenLink`"] data3D = N@Flatten[Table[{r Cos[phi], r Sin[phi], z}, {phi, 0, 2 Pi, .5}, {z, -4, 4, .5}, {r, .2, 1, .4}], 2]; in = TetGenCreate[]; TetGenSetPoints[in, data3D]; out = TetGenTetrahedralize[in, ""]; coords = TetGenGetPoints[out]; meshElements = TetGenGetElements[out]; ...


10

first part..i had lying around.. poly = Random[Real, {1, 2}] {Cos[#], Sin[#]} & /@ Sort[Table[Random[Real, {0, 2 Pi}], {5}]] isLeft[P2_, {P0_, P1_}] := -Sign@Det@{P2 - P0, P1 - P0}; pinpoly[p_, poly_] := Module[{ed},(*winding rule*) ed = Partition[Append[poly, poly[[1]]], {2}, 1]; Count[ed,pr_ /; (pr[[1, 2]] <= p[[2]] < pr[[2, 2]] ...


10

First, you can generate your random points like so: SeedRandom[1]; pts = RandomReal[{0, 12}, {100, 2}]; The DelaunayTriangulation command returns an adjacency list representation of the triangulation. Needs["ComputationalGeometry`"]; dt = DelaunayTriangulation[pts]; dt // Column This says that the first point should be connected to the 2nd, the 24th, ...


9

You can add the mesh specific to the x and y coordinates of your data with Mesh -> {First /@ bData, #[[2]] & /@ bData}: p1 = ListPointPlot3D[bData, PlotStyle -> PointSize[Large]] p2 = ListPlot3D[bData, MeshStyle -> Red, PlotStyle -> None, Mesh -> {First /@ bData, #[[2]] & /@ bData}, InterpolationOrder -> ...


9

Here's a possible approach. First use TetGen to tetrahedralize the data: Needs["TetGenLink`"] {pts, tetrahedra} = TetGenDelaunay[data3D]; Next define a function to compute the radius of the circumsphere of a tetrahedron (formula from Wikipedia) csr[{aa_, bb_, cc_, dd_}] := With[{a = aa - dd, b = bb - dd, c = cc - dd}, Norm[a.a Cross[b, c] + b.b ...


9

As pointed out in the comments, there's really no mathematical definition of a concave hull. Of course, just because there's no mathematical definition does not preclude coming up with something that sort of works. I can think of two ways to do this: Easy Way, Not General Your data roughly has axial symmetry parallel to the x-axis. Moreover, all of your ...


8

This will do densPlot = DensityPlot[ 4 Sin[2 Pi x] Cos[1.5 Pi y] (1 - x^2) (1 - y) y, {x, -1, 1}, {y, 0, 1}, MeshStyle -> Thick, Mesh -> All]; vertexCoordinates = densPlot[[1, 1]]; length = Length[vertexCoordinates]; graphReadyConnections = DeleteDuplicates@ Flatten[ Cases[#, List[x_, y_, z_] :> {Sort[x ...


8

GridLines works in Graphics Graphics[{ {Thick, Darker[Red], Arrow[{{0, 0}, {1, 1}}]}, {Dashed, Arrow[{{0, 0}, {1, 0}}]}, {Dashed, Arrow[{{1, 0}, {1, 1}}]}, Text[Style["R", Italic, Large], {.5, .5}, {0, -1}], Text[Style["\[Theta]", Large], {.2, .1}, {-1, 0}] }, GridLines -> Automatic, GridLinesStyle -> LightGray, PlotRange -> {{-1, 2}, ...


7

Here is an (imperfect) starting point for how to use ListSurfacePlot3D with this example. It needs manual refinement, but I only have time for this quick test: pts = Import["http://dl.dropbox.com/u/68983831/tube01.vtk", "VertexData"]; Show[Map[ListSurfacePlot3D[#] &, Partition[pts, 300]]] The idea is to break the over 6000 points in your shape ...


6

As I said before, there really isn't such a thing as a concave hull. What you want to do is plot your clusters here. The first problem involves a machine vision problem known as 3D segmentation. Mathematica doesn't have any tools out of the box to do this, as far as I know. One way is to guess how many "clusters" are in your data, although that's hard to ...


6

It seems you are asking for the Delaunay triangulation. There's a function for this in the Computational Geometry package, which Mark described. Another, usually much faster option is using ListDensityPlot: ldp = ListDensityPlot[ArrayPad[p0, {0, {0, 1}}], Mesh -> All, ColorFunction -> (White &)] You can extract the polygons from this ...


6

With your data you could try to specify the divisions of the Mesh to match your x and y coordinates: p1 = ListPointPlot3D[bData, PlotStyle -> PointSize[Large]]; p2 = ListPlot3D[bData, MeshStyle -> Red, PlotStyle -> None, Mesh -> {Union[bData[[All, 1]]], Union[bData[[All, 2]]]}, InterpolationOrder -> 10, PlotRange -> All]; Show[p1,p2] ...


6

This doesn't really answer the question, but might help you with your investigations... By setting the system option "VisualizationOptions" -> {"Verbose" -> True} you get all sorts of information printed about the plotting process. The code below intersperses that output with the actual sampled points (shown as ListPlots), showing the initial sampling ...


6

If you don't mind using undocumented functions, you can do it like this: Graphics`Mesh`MeshInit[]; mesh = DensityPlot[4 Sin[2 Pi x] Cos[1.5 Pi y] (1 - x^2) (1 - y) y, {x, -1, 1}, {y, 0, 1}, Method -> {"ReturnMeshObject" -> True}]; Graph[mesh["Edges"], VertexCoordinates -> mesh["Coordinates"], VertexShapeFunction -> (Point[#] &)]


6

At OP's behest: The easiest approach to see the mesh lines is to remove the EdgeForm[] instruction that causes them not to appear. For instance, DeleteCases[Import["ExampleData/wrench.obj.gz"], _EdgeForm, ∞] As SEngstrom suggests, you can also use a replacement rule. If, for instance, you want a thick gray mesh, here's what you can do: ...


5

You could put caps on your cylinder and control the mesh with PlotPoints and MaxRecursion: Show[ ParametricPlot3D[{r Cos[phi], r Sin[phi], 4}, {phi, 0, 2 Pi}, {r, 0, 1}, Mesh -> All, PlotPoints -> {25, 4}, MaxRecursion -> 0], ParametricPlot3D[{r Cos[phi], r Sin[phi], -4}, {phi, 0, 2 Pi}, {r, 0, 1}, Mesh -> All, PlotPoints -> {25, 4}, ...


5

The procedure I suggested for your other "concave hull" question seems to work reasonably well here, simultaneously isolating the clusters and creating the surfaces. Needs["TetGenLink`"]; {pts,tetrahedra}=TetGenDelaunay[data3D]; csr[{aa_,bb_,cc_,dd_}]:=With[{a=aa-dd,b=bb-dd,c=cc-dd}, Norm[a.a Cross[b,c]+b.b Cross[c,a]+c.c Cross[a,b]]/(2Norm[a.Cross[b,c]])]; ...


5

What about this: Import["ExampleData/wrench.obj.gz", "PolygonObjects"] // Graphics3D You can use the FaceForm[None] trick as shown by @J.M. here just as well if you only want the wireframe looks.


5

The problem with the data is that those are sets of almost vertical lines, so it is not a function on {x,y} domain. ListPlot3D is trying to get such surface but it is impossible. We can use the trick to plot not {x,y,z} but {z, x, y} which is a function on {z, x}. data2 = data[[ ;; , {3, 1, 2}]]; pica = Graphics3D[Sphere[data2, 0.1]]; picb = ...



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