Tag Info

110

Well, the answer seems to be YES :) Here is my implementation of Minecraft classic game in Mathematica. Let’s start with some screenshots which were taken during the construction of the final scene which will be displayed an the end of this post. Features Blocks are creatable and removable One texture per block Player automatically jumps to the ...

49

Here's one way to slice the donut. To draw one half of the sliced donut I'm using a parameterisation of a torus similar to the one on wikipedia, but with v replaced with u + v and v running from 0 to Pi instead of 2 Pi. This means that the cut is actually a double twist loop. pl = ParametricPlot3D[{{Sin[u] (2 + Cos[u + v]), Cos[u] (2 + Cos[u + v]), Sin[u + ...

33

Solution 1: Using 3D Texture with Polygons The idea is to use Polygon with 3D texture supported by Texture, but it requires a bit of undocumented hack to make it smooth. The original data set is from Stanford Graphics Group website. The dataset that has been used is CThead, 8-bit tiffs (download). Before proceed, make sure that you have a plenty of memory ...

26

UPDATE: latest Mathematica 9 functionality This is very easy now with latest Mathematica 9 functionality. Just use Image3D or Raster3D functions: data = DeveloperToPackedArray[With[{step = .03}, ParallelTable[Exp[-(i^2 + j^2 + k^2)^4/.99], {k, -1.2, 1.2, step}, {i, -1.2, 1.2, step}, {j, -1.2, 1.2, step}]]]; Image3D[data, ColorFunction -> #, ...

20

One way to extrude a 3D object from a binary 2D image is to use RegionPlot3D: pts = ImageData[ColorNegate@Binarize@Import["http://i.stack.imgur.com/UWO6k.png"], "Bit"]; g = RegionPlot3D[pts[[Sequence @@ Round@{i, j}]] == 1, {i, 1, #1}, {j, 1, #2}, {z, 0, 1}, PlotPoints -> 100, Mesh -> False, Axes -> False, Boxed -> False] & @@ ...

18

The idea is quite simple: Since any great circle can be parametrized as $\cos(\theta)u + \sin(\theta)v$ where $u$ and $v$ are two orthonormal vectors. One can start with $u=\{1,0,0\}, v=\{0,1,0\}$ and use RotationTransform to get out of the xy plane, then use RotationTransform again to spin around the z-axis to get all great circles with desired inclination. ...

17

There are some tricks ... Specifying the prism's vertices is enough (you don't need to take care of the faces) if you use some undocumented methods for finding the convex hull: v = {{2/3, 1/2, 0}, {2/3, 1/2, 1}, {2/3, 1, 0}, {2/3, 1, 1}, {3/2, 1/2, 0}, {3/2, 1, 0}}; ...

16

The important image operation you need is called Skeletonization or Thinning. Different approaches are possible, but as far as I can see, you are interested in the medial axis of your black object. Here is one simple recipe to create a 3D tubular medial axis from your image: take the image and invert the colors, because in image processing the convention ...

15

This following code that uses TetGen we will compute the volume of the convex hull. Needs["TetGenLink"]; TetraMaker[pts_, surface_, TetGenString_?StringQ] := Module[{inInst, outInst, coords, surface1, meshElements, facets}, inInst = TetGenCreate[]; TetGenSetPoints[inInst, pts]; facets = Partition[surface, 1]; ...

15

Unfortunately, I see more than one point why your approach will not work like you hope. Let me give a completely different approach which consumes some memory but is really short. The trick is to use ListContourPlot3D and to create the input-volume from your image which you use as slices. The only thing you have to remember is that you have to pad your ...

15

If you want to plot a distribution that is three dimensional then first you need to form it! SmoothDensityHistogram plots a smooth kernel histogram of the values $\{x_i,y_i\}$ but as we have three dimensional data here we need the function called SmoothKernelDistribution! data = RandomReal[1, {1000, 3}]; dist = SmoothKernelDistribution[data]; Now you ...

15

If you dig through Eric Weisstein notebook you can find this well parametrized version. I changed parameters and styles a bit to get closer to your shape. With[{R = 1.2, r = 1/2, a = Sqrt[2]}, ContourPlot3D[-a^2 + ((-r^2 + R^2)^2 - 2 (r^2 + R^2) ((-r - R + x)^2 + y^2) + 2 (-r^2 + R^2) z^2 + ((-r - R + x)^2 + y^2 + z^2)^2) ((-r^2 + ...

14

Perhaps an idea could be combine an unblurred image of a Graphics3D with a blurred one and having their view dynamically controlled. I am not too deft at image processing nor I have time now, but this will show the idea. DynamicModule[{vp = Options[Graphics3D, ViewPoint][[1, 2]], va = Options[Graphics3D, ViewAngle][[1, 2]], vv = Options[Graphics3D, ...

14

GraphicsComplex is probably what you are looking for. For example, define the vertices for the 3D polygon: v = {{2/3, 1/2, 0},{2/3, 1/2, 1},{3/2, 1/2, 0},{2/3, 1, 0},{2/3, 1, 1},{3/2, 1, 0}}; and make a list of which vertices should connect to each other: i = {{1, 2, 3}, {4, 5, 6}, {1, 2, 5, 4}, {1, 3, 6, 4}, {2, 3, 6, 5}}; The first two elements of i ...

14

Use ShearingTransform: Graphics3D[{Polygon[{{-1.5, -1.5, 0}, {1.5, -1.5, 0}, {1.5, 1.5, 0}, {-1.5, 1.5, 0}}], Polygon[{{-1.5, 0, -1.5}, {1.5, 0, -1.5}, {1.5, 0, 1.5}, {-1.5, 0, 1.5}}], Opacity[0.5], GeometricTransformation[Cylinder[{{-1, 1, 0}, {0.0, 0, 0}}, 0.2], ShearingTransform[ -Pi/4, {-1, 1, 0}, {1, 1, 0}]], ...

13

I think the basic idea is to create two slightly different views and combine them in the red and (green + blue) channels. p = Plot3D[Sin[x y]^2, {x, -2, 2}, {y, -2, 2}]; {r, g} = ColorConvert[ Image[Show[p, ViewPoint -> {3 Sin[#], 3 Cos[#], 2} &[# Degree]], ImageSize -> {360, 275}], "Grayscale"] & /@ {141, 139}; ColorCombine[{r, g, g}] ...

13

I decided to post another answer for several reasons: I made up a full working contraption by using another approach The previous answer could be useful for others, so I prefer to leave it there Both answers are quite long, and having both in one post will clutter it That said, the plan is the following: Collapse the points as before, pre-clustering ...

13

The issue has nothing to do with Texture. It is because the polygon you define in add is at the same plane where the front wall is: if you only use e.g. a red polygon instead of a textured one, you still would see the blinking feature, as Mathematica fails to decide which polygon to draw before the other: the wall or the red one. So you can simply move the ...

13

Here is a static solution to the problem. It shows a mesh on the sphere that represents the normal lat-long coordinate system. A function representing the equator. equator[θ_] := {Cos[θ], Sin[θ], 0} A function and a plot representing the inclined circle. Note that the inclination is accomplished by a rotation of the equator about the x-axis. ...

13

You can always hide away the coordinate transformations inside a function that calls RegionPlot3D. Here's a quick & dirty sphericalRegionPlot3D: sphericalRegionPlot3D[ ineq_, {r_, rmin_: 0, rmax_: 1}, {th_, thmin_: 0, thmax_}, {ph_, phmin_, phmax_}, opts___] := RegionPlot3D[With[{ r = Sqrt[x^2 + y^2 + z^2], th = ArcCos[z/Sqrt[x^2 + y^2 + ...

13

Since ConvexHull doesn't support 3D points (and you incorrectly tried to compute the ConvexHull of the Graphics object) your code didn't work. Here is one way to do what I think you want (I left out of the step of the Cuboids but if you want that basically just offset your convex hull). Needs["TetGenLink"] pos = Position[DiskMatrix[{12, 10, 8}], 1]; ...

12

I'm not sure if this comes close to what you had in mind, but I hope it helps. Moving a sphere will move the other spheres as well. The distance over which the spheres are moved depends on their strength, the strength of the sphere being moved and the distance between the two spheres. The size of the spheres indicates their strength. The function ...

12

How about using far-away ViewPoint coordinates? The left one uses the default ViewPoint, the right one has parallel projection. { Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, ViewPoint -> {1.3, -2.4, 2.0}], Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, ViewPoint -> {1.3, -2.4, 2.0}*1000] } You can also directly prettify the labels and ticks: ...

12

Because the image of the group under this (linear) representation is infinite, we will need to limit the orbits. Working in the abstract group Presuming it may eventually be of interest to depict multiple orbits, let's compute a large number of group elements once and for all. It seems efficient to do this abstractly, in terms of the given presentation, ...

12

map = Import["http://upload.wikimedia.org/wikipedia/commons/e/e3/China_old_map.jpg"] {w, h} = map // ImageDimensions; The route: route = {{1107.07, 184.181}, {1096.17, 198.195}, {1072.81, 237.121}, {1071.25, 244.906}, {1068.14, 254.249}, {1065.03, 265.148}, {1063.47, 274.49}, {1063.47, 286.947}, {1063.47, 296.289}, {1063.47, 308.746`}, ...

12

Here's your approach, but with 3D primitives. You can then move the camera around using your own definition for ViewVector (or you can steal Sjoerd's): Module[{mapZ = 0, mapDim = ImageDimensions@map, arrowZ = 5, ordering}, Graphics3D[ { {Texture@map,Polygon[ List[##, mapZ] & @@@ Tuples[Transpose@{{0, 0}, mapDim}] ...

12

While not positive, I believe the answer is that RegionPlot does not support spherical (or other non-Cartesian) coordinates natively. If correct, I guess the question becomes "What's the easiest way to plot a region defined in terms of spherical coordinates, without resorting to converting the equations by hand?" V9 has commands to ease this process. ...

12

I'll just dissect a little @J.M.'s answer for you: First define a path: path = ParametricPlot3D[ BSplineFunction[{{0, 0, 0}, {1, 1, 1}, {2, -1, -1}, {3, 0, 1}, {4, 1, -1}}][u] // Evaluate, {u, 0, 1}, MaxRecursion -> 1] Now extract the Line[] definitions from that plot: pathL = First@Cases[path, Line[l_] :> l, ...

11

Try the following: In[2]:= Cases[myGraphics, Polygon[pts_] -> pts, Infinity] Out[2]= {{{0, 0, 0}, {0, 0, 300}, {0, 300, 300}, {0, 300, 0}}} If your Graphics3D object had many polygons you would get a list comprised of lists of the vertexes of all of them. Update In response to István Zachar's commentL: to confine the pattern to match only 3D ...

11

One possible way is to use Graphics3D with Point and color points by function value so it's like density plot 3d. For example, xyz = Flatten[ Table[{i, j, k}, {i, 1, 10, .35}, {j, 1, 10, .35}, {k, 1, 10, .35}], 2]; f[x_, y_, z_] := x^2 y Cos[z] Graphics3D[ Point[data, VertexColors -> (Hue /@ Rescale[f[##] & @@@ data])], ...

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