Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm creating 3D nebulae models for Celestia, a free OpenGL astronomy software. The following question is in part related to another one I already asked on this forum (see this question, for which I now have a complete answer.

I also want to create some irregular nebulae, a bit like the Orion and the Carina nebulae (see this page on Wikipedia, about the Carina nebula). In this case, there is no symetry to help building the model, so I was thinking about some random walks. The following code draws a bunch of random walks in 3D, and is working very well (it could be simplified a bit, but this isn't the question) :

RandomWalkCoords = Flatten[
   Table[
      {x, y, z} = {RandomReal[{-10, 10}], RandomReal[{-10, 10}], RandomReal[{-10, 10}]};
      p = 0.1;
      {u, v, w} = {0.0, 0.0, 0.0};
      NestList[(
         u += RandomReal[NormalDistribution[0, s]];
         v += RandomReal[NormalDistribution[0, s]];
         w += RandomReal[NormalDistribution[0, s]];
         # + p {u, v, w}) &,
         {x, y, z},
         50], 
     {s, 0.1, 1, 0.05}],
   1];

max = Max[Norm/@RandomWalkCoords];

PlotColors = ColorData["SunsetColors"];
Graphics3D[
   Table[
      {x, y, z} = {RandomReal[{-10, 10}], RandomReal[{-10, 10}], RandomReal[{-10, 10}]};
      p = 0.1;
      {u, v, w} = {0.0, 0.0, 0.0};
      Line[
         NestList[(
            u += RandomReal[NormalDistribution[0, s]];
            v += RandomReal[NormalDistribution[0, s]];
            w += RandomReal[NormalDistribution[0, s]];
            # + p {u, v, w}) &,
            {x, y, z},
            50]],
      {s, 0.1, 1, 0.025}],
   Axes -> True, 
   AxesStyle -> Opacity[0.25], 
   AxesOrigin -> {0, 0, 0}, 
   SphericalRegion -> True, 
   PlotRange -> {{-25, 25}, {-25, 25}, {-25, 25}}]

Graphics3D[
   {PlotColors[Norm[#]/max], Sphere[#, 0.1]} &/@RandomWalkCoords,
   Boxed -> False, 
   Background -> Black, 
   Lighting -> "Neutral", 
   SphericalRegion -> True]

So my question is this: I need to "blurr" the distribution of points around each random walk path; i.e., the points should be scattered randomly (using some kind of thickness parameter) so the curves take on volume. They should represent clouds of gas and dust in the nebula. How should I do this ?

The "thickness" parameter should also be random for each random walk. There should be another parameter to control the global rendering.

Take note that I'm working on Mathematica 7.0. So your suggestions should be compatible with this version.

EDIT Using a variation of the code below, I'm now able to generate some very nice nebula models. Here's an example, as seen in Celestia : A nebula in Celestia. It may look a bit timid, crude and simplistic, but this is just a first experimental version.

share|improve this question

closed as too localized by Jens, m_goldberg, Sjoerd C. de Vries, Verbeia Mar 13 '13 at 9:43

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
From the downvotes one can deduce that you should try to formulate the question in a more Mathematica specific way so that people don't have to embark on an open-ended research project to answer it. BTW, I didn't downvote, just trying to improve the chances of making this useful for others. –  Jens Mar 13 '13 at 5:07
4  
Perhaps people are worried that you're going to work your way through the entire universe and want to discourage you a bit. But it might be a good idea to generalise your questions a bit, as Jens said. –  cormullion Mar 13 '13 at 8:01
add comment

1 Answer 1

up vote 3 down vote accepted

Revised:

The last one was pretty ugly. What about this (MM7 adjustments needed):

arms=Table[NestWhileList[{#[[1]]+RandomInteger[{-2,1}],#+RandomReal[{-1,1}]&/@#[[2]]}&,{RandomInteger[{25,30}],{0,0,0}},#[[1]]>15&],{10}];
points=Table[#+RandomVariate[MixtureDistribution[{1,1},{NormalDistribution[-.1,.3],NormalDistribution[.1,.3]}]]&/@#[[2]],{#[[1]]}]&/@Flatten[arms,1];
ListPointPlot3D[points,BoxRatios->{1,1,1},ImageSize->800,PlotStyle->{Blue,PointSize[Small]}]

enter image description here

share|improve this answer
    
It's working ! However, I had to replace "RandomVariate" to "RandomReal" for it to work in Mma v7.0. The problem with the output is the density. I think we should have some space between the clouds (fuzzy random walk curves). Is there any other suggestions, to simulate asymetrical nebulae ? –  Cham Mar 12 '13 at 23:49
    
How do set the total number of particles in your code ? Or the number per curve ? –  Cham Mar 13 '13 at 1:09
    
@Cham: My first suggestion was pretty lackluster so I just dropped it. The new one has more parameters to tinker with. –  mfvonh Mar 13 '13 at 7:16
    
this code isn't working with Mma 7.0. I have to change "RandomVariate" to "RandomReal", but it isn't enough. I suspect "MixtureDistribution" isn't compatible with v7.0. –  Cham Mar 13 '13 at 9:40
    
Try replacing the mixed disctribution with a single normal distro. –  mfvonh Mar 13 '13 at 9:49
show 8 more comments

Not the answer you're looking for? Browse other questions tagged or ask your own question.