Tag Info

Hot answers tagged

13

You can fix this problem by using the following Option in Graphics3D: Method -> {"CylinderPoints" -> {200, 1}} Adjust 200 to match your requirements. (Indeed the default is 40.) Edit: I don't know exactly what the second parameter does, but using the single parameter form shown in the documentation linked below results in a big slow-down. I ...


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, ...


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 ...


7

The direct answer has been given by Mr. Wizard already, but there is also another way that renders smoothly while giving some additional advantages: Use Tube instead of Cylinder. One advantage is that Tube allows you to do additional styling with VertexColors, not supported by Cylinder. I will assume that we named your large list of Cylinder objects ...


6

Note: this response was written before sample data for the question was changed from 24 3D points to 96 2D points. The main message remains unchanged, however. The error message is complaining that the first zero in the first polygon specification is not a valid index into the list coord which has 24 elements. A GraphicsComplex defines a list of points of ...


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, ...


4

Im sorry i have a bit limited time at the moment so the answer will need to be revisited later. While its true that the hardware of your computer could do this, and it could be included in by wolfram making shadows is usually considered a next step in rendering. I am not dwelling on why this doesn't work, as you can use any of the existing free raytracers ...


4

Here is the general answer for any shaped object of surface genus-0, though it can have holes as long as it's an outer boundary (maybe its more general and someone can correct me). I will first describe the general UV mapping. This is usually done for a surface with a pre-chosen boundary, you need to choose which points are part of the boundary and give ...


4

Here's a replacement for Cylinder that uses splines. Clear[splineCylinder]; splineCylinder[{a_, b_}, r_: 1] := Module[{ base = r {{0, -1, 0}, {1, -1, 0}, {1, 1, 0}, {0, 1, 0}, {-1, 1, 0}, {-1, -1, 0}, {0, -1, 0}}, weights = {1, 0.5, 0.5, 1, 0.5, 0.5, 1}, knots = {0, 0, 0, 1/4, 1/2, 1/2, 3/4, 1, 1, 1}, transform, baseA, baseB ...


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 ...


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]


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 ...


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, ...


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]


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 ...


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. ...


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]


1

You need to use the option BoxRatios -> Automatic. ListPointPlot3D[{{0, 0, 0}, {1, 2, 3}}, BoxRatios -> Automatic]


1

Perhaps you could hack together disks using a plotting function (and use PlotPoints if necessary)? PolarPlot[1, {\[Theta], 0, 2 Pi}, PlotPoints -> 1000]; Cases[%, _Line, Infinity] /. {p__?NumberQ} :> {p, 0}; %[[1,1]] // Length %% // Graphics3D 1761


1

Something along these lines? Just want to make sure. Hard to put in the comment. If not will delete. Manipulate[ Graphics3D[{Green, Cuboid[{t, 0, Sin[t]}]}, Axes -> True, PlotRange -> {{-2 Pi , 2 Pi}, {-1, 1}, {-2, 2}} ], {t, -2 Pi, 2 Pi, .1}]


1

I've used Assimp for this, though I have never managed to preserve box ratios, the bounding box, or the view point. Graphics3D[{ Red, Cuboid[], Blue, Cylinder[]}]; Export["g.lwo", %] Run["assimp.exe export g.lwo out.dae"] For OS X, pre-compiled Assimp binaries are available in MacPorts.



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