|
|
Matthew Green wrote:
>
> I want to create a ring of random width made of randomly spaced particles.
>...
Hello Matthew
POV-Ray has some very useful built in functions that you
can use for this. So there's no need to do this "manually"
as you seem to be doing.
See my example code below.
It uses the vrotate() function (as also Margus suggested).
--
Best regards,
Tor Olav
mailto:tor### [at] hotmailcom
http://hjem.sol.no//t-o-k/tokpicts.html
http://www.crosswinds.net/~tok
>...
> What I get is random particles within a square boundary. I've stared at
> this for 45 minutes now. Where am I screwing up?
> looprun, ringminrad1, ringwidth1, seed1-4, and deftex are all previously
> declared.
>
> #while (looprun < 4000)
> #declare x1 = (ringminrad1 + (ringwidth1 * rand(seed1))) *
> cos(radians(90*rand(seed2)));
> #declare z1 = (ringminrad1 + (ringwidth1 * rand(seed1))) *
> sin(radians(90*rand(seed2)));
> #declare posnegx = rand(seed4);
> #if (posnegx < 0.5)
> #declare posnegx = -1;
> #else
> #declare posnegx = 1;
> #end
> #declare posnegz = rand(seed4);
> #if (posnegz < 0.5)
> #declare posnegz = -1;
> #else
> #declare posnegz = 1;
> #end
> sphere {
> <0,0,0>,1
> rotate <90*rand(seed3),90*rand(seed3),90*rand(seed3)>
> scale <rand(seed3),rand(seed3),rand(seed3)>
> translate <posnegx * x1,rand(seed3),posnegz * z1>
> texture {deftex}
> }
> #declare looprun = looprun + 1;
>
> #end
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
#version 3.1;
#include "colors.inc"
global_settings { ambient_light color -White }
background { color Blue/2 }
light_source {
50*<-2, 1, -1>
color White + Yellow
}
camera {
location 15*<0, 1, -2>
look_at <0, -2, 0>
}
#declare DefTex = texture { pigment { color White + Blue } }
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
#declare RingMinRad = 12;
#declare RingWidth = 4;
#declare RR = seed(314);
#declare LoopRun = 0;
#while (LoopRun < 4000)
#declare Radius = RingMinRad + RingWidth*rand(RR);
#declare Angle = 360*rand(RR);
#declare Vector = Radius*vrotate(x, Angle*y);
sphere {
<0, 0, 0>, 1
scale <rand(RR), rand(RR), rand(RR)>
rotate 90*<rand(RR), rand(RR), rand(RR)>
translate Vector + rand(RR)*y
texture { DefTex }
no_shadow
}
#declare LoopRun = LoopRun + 1;
#end // while
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
Post a reply to this message
|
|