Tag Info

Hot answers tagged

313

I have to confess that I see this as a proper challenge, as I am usually quite creative in finding/combining functions to provide a desired behavior. So I will give it another try. which is generated using box[x_, x1_, x2_, a_, b_] := Tanh[a (x - x1)] + Tanh[-b (x - x2)]; ex[z_, z0_, s_] := Exp[-(z - z0)^2/s] and r[z_, x_] := (*body*).4 (1.0 - .4 ...


181

This might get me suspended from the site butt I cannot resist. The shape you are looking for can probably be approximated (depending how anal you want to be about the outcome) by two assymetric probability distributions. The obvious choices would be a Poasson or a log normal distribution. I will use the latter as it is continuous. Now the bummer is that ...


164

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


88

Parametric Buttocks Manipulator Manipulate[ ParametricPlot3D[{ (e u^p + (1 + (c - a u) (u - 1)) Cos[t]^2) Sin[t], (e u^p + (1 + (d - b u) (u - 1)) Cos[t]^2) Cos[t], 2 u}, {t, -0.2, Pi + 0.2}, {u, 0, 1.1}, Lighting -> "Neutral", Mesh -> None, PlotStyle -> Directive[Specularity[0], RGBColor[0.92, 0.85, 0.73]], Axes -> False], {{a, ...


56

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


47

Yes we can. The following DashedGraphics3D[ ] function is designed to convert ordinary Graphics3D object to the "line-drawing" style raster image. Clear[DashedGraphics3D] DashedGraphics3D::optx = "Invalid options for Graphics3D are omitted: `1`."; Off[OptionValue::nodef]; Options[DashedGraphics3D] = {ViewAngle -> 0.4, ViewPoint ...


43

Answer Apparently, the mesh lines generate points which are too close to the triangle vertices, and VRML is not being able to handle them correctly. To prove the theory, try the example without meshes: p = ParametricPlot3D[{(2 + Cos[v]) Sin[u], (2 + Cos[v]) Cos[u], Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, PlotStyle -> Red, Mesh -> None]; ...


41

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


40

First of all let me tell you that you should wait for some great submissions from other members. Maybe @Yu-SungChang will post some FPS game here ;-). I just will give you the prototype I happen to write recently for an unrelated task. I could fly around your example too but it is too slow (and cool ;-) ) - I will demo some more fluid but simple environment. ...


40

We can do this by building a regular hexagon tile and wrapping it onto a torus: hexTile[n_, m_] := With[{hex = Polygon[Table[{Cos[2 Pi k/6] + #, Sin[2 Pi k/6] + #2}, {k, 6}]] &}, Table[hex[3 i + 3 ((-1)^j + 1)/4, Sqrt[3]/2 j], {i, n}, {j, m}] /. {x_?NumericQ, y_?NumericQ} :> 2 π {x/(3 m), 2 y/(n Sqrt[3])} ] ht = ...


39

I'm posting this as a second answer, as it's really a completely different approach. It's also been substantially expanded as of April 25, 2012. While this still doesn't specifically address the question of adding a region, it does plot the countries separately. Of course, each country could be viewed as a region in itself. Our objective is to make a ...


30

UPDATE: latest Mathematica 9 functionality This is very easy now with latest Mathematica 9 functionality. Just use Image3D or Raster3D functions: data = Developer`ToPackedArray[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 -> #, ...


29

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


28

Well, an unusual question to answer, what about something like this Plot3D[.7*(1 + Tanh[1 - (2*Y^2 + X^2 + X^4)]) - .3*Exp[-X^2/.0025]* Exp[-(Y - .1)^2/.15] - .2*(Exp[-(X - .7)^2/.02]*Exp[-(Y - .0)^2/.08] + Exp[-(X + .7)^2/.02]*Exp[-(Y - .0)^2/.08]), {X, -1, 1}, {Y, -1, 1}]


27

Note that ViewPoint is given in specially scaled coordinates which depend on amongst things the size of the bounding box. To get better control over the positioning of the camera you could use ViewVector instead, which is given in terms of the coordinates of the plot. You could for example do something like this: rotateMeHarder1[g_, vertical_, viewpoint0_, ...


25

This is not a direct response to the question but rather a response to Istvan's comment to FJRA answer. As Istvan points out, the 3D globe has "artefacts like excess polygon-parts". An alternative approach is to use ParametricPlot3D together with a 2D map as a texture. Here's the result. SeedRandom[4]; countries = Table[{ColorData["DarkTerrain"][Random[]], ...


25

I doubt you can find a chart for all options, but take a look at this: For this and other insights two courses by Yu-Sung are a must (there are notebooks and videos there): Graphics Language Quick Start Visualization: Advanced 3D Graphics The above chart is from the 1st one. The one @Kuba links in the comment to your question is from the 2nd - I ...


25

Yet another method: Let us calculate values of function on appropriate rectangular grids, which we will convert to textures (1 pixel = 1 value). Interpolation between pixels is built-in. f = 2 #1^2 + 2 #2^2 + #3^2 + #1 #2 &; PolyhedronData["Cube"] // N // Normal // toTriangles // texturize[f, 50, Hue, Lighting -> "Neutral", Axes -> True] ...


24

A major point behind the video is that Mobius transformations are simplest when viewed on the sphere. Thus, we'll never actually define a Mobius transformation - we'll do that part on the sphere. Of course, we will need to project back and forth. Here are the stereo graphic projection and it's inverse implemented as compiled functions for speed. This is ...


23

This maybe helpful if you want to convert image structure into 2D/3D line primitives, MorphologicalGraph does some astonishing things out of the box: img = Import[ "https://upload.wikimedia.org/wikipedia/commons/c/ce/Spinnennetz_\ im_Gegenlicht.jpg"]; g = MorphologicalGraph[img // MorphologicalBinarize, VertexCoordinates -> Automatic, ...


23

One can also use MeshFunctions: Clear[f]; f = {x, y, z} \[Function] x + Sin[5 z] + y^2; cube = PolyhedronData["Cube", "RegionFunction"]; mesh = 15; RegionPlot3D[cube[x/2, y/2, z/2], {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, MeshFunctions -> {f}, Mesh -> mesh, MeshShading -> ColorData["Rainbow"] /@ Range[0, 1, 1/(mesh + 1)], PlotPoints -> 50, ...


21

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[xyz, VertexColors -> (Hue /@ Rescale[f[##] & @@@ xyz])], ...


21

I propose a small modification to the parametrization for the torus that addresses issues with conformality. Try F[t_, u_, r_] := {Cos[t] (r + Cos[u + Sin[u]/r]), Sin[t] (r + Cos[u + Sin[u]/r]), Sin[u + Sin[u]/r]} instead. Next, we wish to choose suitable values for $m, n$ for a given $r$ such that the mapping of the ...


21

Edit I had some time so I've added full surface torus. Old code in edit history. DynamicModule[{x = 2., l = 100., x2 = 2., l2 = 100., grid, fast, slow}, Grid[{{ Graphics3D[{ Dynamic[Map[{Blue, Polygon[#[[{1, 2, 4, 3}]]]} &, Join @@@ (Join @@ Partition[#, {2, 2}, 1]) ]&[ ...


20

You can use Inset: Show[{Graphics3D[{Opacity[0.2], Sphere[], Opacity[1.0], Blue, Inset[Graphics[Text[Style["Surprise!", Green, 24]]], {0, 0, 0}]}], ParametricPlot3D[{Sin[th] Cos[ph], Sin[th] Sin[ph], Cos[th]}, {th, 0, Pi}, {ph, 0, 2 Pi}, RegionFunction -> Function[{x, y, z}, Abs[x] < .9], PlotRange -> {-1, 1}, PlotStyle -> ...


20

Here's a rather simple first attempt using RegionPlot3D to define a solid with Voronoi cell type voids. I start with a set of random void locations. The region function says that a point is in the solid if the distance to the nearest void centre is almost the same as the distance to the second nearest void centre (i.e. we are close to a Voronoi cell ...


19

You could use a combination of Translate and Scale. Suppose the radii and centres of the circles are given by radii = RandomReal[{.1, .6}, 8]; centres = RandomReal[{-2, 2}, {8, 3}]; Then using the original sphere image = ExampleData[{"ColorTexture", "GiraffeFur"}]; sphere = SphericalPlot3D[1, {theta, 0, Pi}, {phi, 0, 2 Pi}, Mesh -> None, ...


19

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] & @@ ...


19

The following is probably what you want. Make3d[plot_, height_, opacity_] := Module[{newplot}, newplot = First@Graphics[plot]; newplot = N@newplot /. {x_?AtomQ, y_?AtomQ} :> {x, y, height}; newplot /. GraphicsComplex[xx__] :> {Opacity[opacity], GraphicsComplex[xx]} ] Show[{Graphics3D[Make3d[twoDptsPlot, -1, .75]], ...


19

Here's a start: perforateaux[pts_, ratio_, indices : {__Integer}] := Module[ {vertices, center, newPts, ind}, vertices = Replace[indices, {{p_, b___, p_} :> {p, b}}]; center = Mean[pts[[vertices]]]; newPts = ratio (# - center) + center & /@ pts[[ vertices]]; ind = MapThread[Flatten[{#1, Reverse[#2]}] &, {Partition[vertices, ...



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