I'm trying to generate a spherical distribution of radial random walk points in 3D space. The following code works, but the random walk lines aren't radial. Why ? Where is my mistake ?
MinSprite := 0.006; (* min radius of sprites *)
MaxSprite := 0.03; (* max radius of sprites *)
SpriteOverlap := 0.75; (* min separation between sprites *)
IterationStep := 0.1;
NumberOfSteps := 20;
thickness = 0.09;
pointsmean = 20;
pointssd = 12;
SpriteSize[p_] := MinSprite + (MaxSprite - MinSprite)Norm[p];
SeedRandom[];
RandomWalk = Flatten[Table[{x,y,z}={dist Sqrt[1 - cosinus^2]Cos[phi],dist Sqrt[1 - cosinus^2]Sin[phi],dist cosinus};
{u,v, w}={0.0, 0.0, 0.0};
dist = RandomReal[{5,10}];
phi = RandomReal[{0,2Pi}];
cosinus = RandomReal[{-1,1}];
velocity = Abs[RandomReal[NormalDistribution[0,s]]];
Line[NestList[(
u+=velocity Sqrt[1 - cosinus^2]Cos[phi];
v+=velocity Sqrt[1 - cosinus^2]Sin[phi];
w+=velocity cosinus;
#+IterationStep{u,v, w})&,{x,y, z},NumberOfSteps]],{s,0.25,0.75,0.007}][[All,1]],1];
CloudsParticles = Flatten[Table[(#+RandomReal@LaplaceDistribution[0,thickness])&/@#,{Max[1,IntegerPart@RandomReal@NormalDistribution[pointsmean,pointssd]]}]&/@RandomWalk, 1];
max=Max[Norm/@CloudsParticles];
NormalizedParticles = CloudsParticles/max;
MinSeparation[p_] := SpriteOverlap SpriteSize[p];
KeepPoint[{p_,q_}] := Norm[p]<Norm[q]||Norm[p-q]>MinSeparation[p];
FilterOnce[pts_] := With[{nf=Nearest[pts]},Select[pts, KeepPoint[nf[#,2]]&]];
PointsCoords = FixedPoint[FilterOnce,NormalizedParticles];
ListPointPlot3D[PointsCoords,BoxRatios->{1,1,1},ImageSize->800,SphericalRegion->True,PlotStyle->{Blue,PointSize[Small]}]
Here's a sample of the output. As you can see, this isn't a radial distribution :
The mistake most probably lies in the RandomWalk declaration, but I can't see it. Anyone has an idea of what may be wrong ?
Take note that I'm using Mathematica 7.0 only.
EDIT :
I must admit that this method isn't a clever way of defining a random distribution of points around radial lines. I'll have to do it differently.