Tag Info

New answers tagged

3

Here, I'll give an approximate solution also based on the Monte-Carlo approach but using very convenient functions introduced in V10. Here it is: pts = Import["https://dl.dropboxusercontent.com/u/68983831/npts.txt", "Table"]; polys = Import["https://dl.dropboxusercontent.com/u/68983831/npolys.txt", "Table"]; cpts = ...


4

This is in theory pretty simple. Think of it as two separated steps. First, you need function that models your extrusion-thickness, which has in the middle always the same value and at both ends it should round up like a circle. You can do this with Piecewise or, as I show here, with a combination of Heaviside functions: thicknessFunc[z_, body_] := ...


1

How about this. Generate a list of 2D points: pts = Table[{Cos[2 \[Pi] k/6], Sin[2 \[Pi] k/6]}, {k, 0, 6}]; ListLinePlot[pts] and we'll use a scaling function to form the caps. Plot[Sqrt[1 - (Abs@z - 1)^2], {z, -1, 1}, AspectRatio -> 1] sfunc[pt_] := Module[{z = Last@pt}, Piecewise[{{pt, -1 < Last@pt < 1}}, {{Sqrt[1 - (Abs@z - 1)^2], ...


7

Because when in Europe... Monte-Carlo! This should work with any shaped tube as long you are given the center points, and a certain resolution, in your case, should be the size of the polygon that make up the surface, or for example the minimum distance between point along the surface. Let's say that distance is dis. First we make a path along the inside ...


3

This might be a bit naive but if you are approximating a cylinder, why wouldn't you simply do the following? pts = Import["https://dl.dropboxusercontent.com/u/68983831/npts.txt", "Table"]; cpts = Import["https://dl.dropboxusercontent.com/u/68983831/cpts.txt", "Table"]; polys = Import["https://dl.dropboxusercontent.com/u/68983831/npolys.txt", "Table"]; fpts ...


2

In Version 10, we can compute the convex hull using ConvexHullMesh p = {{2, 1, 6}, {4, 3, 0}, {5, 2, 5}, {3, 5, 4}} chull = ConvexHullMesh[p] Which we can style using HighlightMesh Show[HighlightMesh[chull, Labeled[1, "Index"]], Graphics3D[{Red, Sphere[p, 0.1]}]]


1

In Version 10 there is such a function. Meet RegionMember. We take your Cylinder primitive as an example: cyl = Cylinder[] Let's create some points: pts = RandomReal[{-1.5, 1.5}, {100, 3}]; Now we create a RegionMemberFunction that can be used repeatedly on various points. mf = RegionMember[cyl] We apply mf to the set of points and give them ...


1

In Version 10, there is now the built-in ConvexHullMesh to do exactly this. pos = Position[DiskMatrix[{12, 10, 8}], 1]; To get the 3D convex hull: ConvexHullMesh[pos]


8

Conway's game of life is a 2D, two-state, outer totalistic, cellular automaton. I guess the natural thing is to try such CAs in 3D. Here's the evolution of one such CA: twos = Array[2 &, {3, 3}]; twosWithOne = twos; twosWithOne[[2, 2]] = 1; outerTotalisticCA3D[ruleNumber_Integer, duration_Integer, init_List] := CellularAutomaton[ {ruleNumber, ...


1

It seems that regularly-spaced mesh parallel to the axes--not the mesh used to create the graphics--can only be drawn for "*Plot" type graphics (and not Graphics3D). Here is my attempt to draw it. Note that I don't know how to combine both types of meshes in one plot--I tried to use BoundaryStyle but it only drew the outline of the shape without the line ...


3

In version 10.0.0 the PlotStyle -> Thickness method shown by cormullion does not appear to work. Instead we can use the undocumented Extrusion option: ContourPlot3D[x y z == 0.05, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Extrusion -> 0.1]


1

You must adjust the Antialiasing Quality to solve that issue. Go to menu Edit -> Preferences -> Appearance -> Graphics.. then adjust it.. That worked for me. I have Ubuntu 14.04 and Mathematica V9. Other solution is open a terminal and run: mathematica -mesa when opening.


1

I have successfully exported many 3D Mathematica objects in the .stl format (used for 3D printing). I use Cheetah3D on the Mac (now $69) to work with the object, add axes or colors, then export as a .dae for use in Collada environments like iBooks Author. Maybe Google Sketchup would also work; it has Collada as a native format but not sure what it imports. ...


3

Something like this? data2D = Import["http://pastebin.com/raw.php?i=0Liw8F1r", "NB"]; data4D = Import["http://pastebin.com/raw.php?i=zgrCRiQh", "NB"]; Find min and max values for the color data {min, max} = {Min[#], Max[#]} &@data4D[[All, -1]]; Now, I place a color in front of each polygon (like {color1, polygon1, color2, polygon2, ...}) when ...


4

In general, I don't think it's possible to use Texture directly with the built-in primitives such as Sphere and Cylinder. See also Texture mapping and resizing a sphere primitive in Mathematica. So you have to write your own replacement for those primitives. Since you specifically mentioned the Cylinder, I added the ability to handle Texture to my answer ...


1

you don't need to use m[x_,y_]:= simply as follow: m = 0.9*Exp[-((x - 1)^2 + (y - 1)^2)] + 0.5 Exp[-(3^2 ((x - 2.5)^2 + (y - 1.5)^2))]; Plot3D[m,{x, 0, 5}, {y, 0, 5}, PlotRange -> All]


8

We could do this with graph theory. Let's turn the polygon structure into a graph: g3 = Graph[UndirectedEdge @@@ Union[Sort /@ Flatten[polys /. {a_, b_, c_} :> {{a, b}, {b, c}, {c, a}}, 1]]] This creates a graph edge for each edge of each triangle, then filters it down to unique edges. For the 2D we need to first join the ends. Let's visually see ...


5

SeedRandom[4]; pts = Table[{x, y, 0.25 + UnitStep[30 - Abs[x] - 0.001] UnitStep[50 - Abs[y] - 0.001] (0.25/RandomReal[{0.1, 2}]^2)}, {x, -30, 30, 5}, {y, -50, 50, 5}]; ParametricPlot3D[ BSplineFunction[pts, SplineDegree -> 2][u, v], {u, 0, 1}, {v, 0, 1}, PlotRange -> All, Boxed -> False, Axes -> False, Mesh -> None, ...


2

It's not a TreeMap using non-rectangles. But maybe can expire someone to go beyond. I believe that I get a nice squarification using this article suggested by @M.R. The code is for Mathematica V10, and can be tested in the WolframCloud. I played with Associations and some others new MMA funcitons as Area and the new @* notation. (*Test Function*) ...


2

See if this will work. It should, since you can get the ImageDimensions of an imported GIF. Note: I changed r1, r2 to Graphics. You can apply f to Graphics or to Image. r1 = Graphics@Rectangle[{-1, -1}, {1, 1}]; r2 = Graphics@Rectangle[{-1, -1}, {0, 1}]; f[img_] := With[{g = ParametricPlot3D[{{t, 0, 0}, {0, t, 0}, {0, 0, t}}, {t, -1, 1}]}, Show[ ...


2

I'm not exactly sure what the output should look like, but I think part of the problem lies in the way you have described Inset, from the documentation: represents an object obj inset in a graphic. Note that your code does not have a graphic into which your Inset is, well, inset. If we redefine f: f[img_] := Show[ParametricPlot3D[{{t, 0, 0}, {0, ...



Top 50 recent answers are included