![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
I want to create a ring of random width made of randomly spaced particles.
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
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
What I'm doing wrong is calling rand twice, once for the x value, the other
for the z, thus getting two different angles for each component. I'm bound
to get weird results that way. I should declare the angle beforehand, thus
getting only a single random value with which to translate to a position.
While I'm at it, if I change those 90s to 360s, I don't have to bother with
the posneg determinations...
No need to reply... I'm an idiot.
Thanks for listening to me babble, though.
- Matthew
"Matthew Green" <iam### [at] yahoo com> wrote in message
news:3aa1386a@news.povray.org...
> I want to create a ring of random width made of randomly spaced particles.
> 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
>
>
>
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Matthew Green wrote :
No need to reply... I'm an idiot.
Thanks for listening to me babble, though.
-------------------------------------------------------------------------
Matthew -
Just in passing - it doesn't require idiocy to make a mistake (plus, idiocy
would preclude the likelihood of correcting your problem); and, your
'babble' taught me something. All-in-all, not a bad day's work. :-)
Setep
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Matthew Green wrote:
>
> I want to create a ring of random width made of randomly spaced particles.
> What I get is random particles within a square boundary. I've stared at
> this for 45 minutes now. Where am I screwing up?
I see you already found the answer to your problem. However I think you could
cut out much of the trig stuff by using POV's built-in vector functions;
v_rotate() in particular seems to do exactly what you need, or perhaps
vaxis_rotate()
--
Margus Ramst
Personal e-mail: mar### [at] peak edu ee
TAG (Team Assistance Group) e-mail: mar### [at] tag povray org
Home page http://www.hot.ee/margusrt
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Matthew Green wrote :
No need to reply... I'm an idiot.
Thanks for listening to me babble, though.
-------------------------------------------------------------------------
Matthew -
Just in passing - it doesn't require idiocy to make a mistake (plus, idiocy
would preclude the likelihood of correcting your problem); and, your
'babble' taught me something. All-in-all, not a bad day's work. :-)
Setep
--------------
Yup ... been there, done that ;)
and . . . in my experience, it is the mistakes that usually lead me to
the most interesting places. Those areas that I never would have
thought to explore . . . the place where most new ideas spring from.
Serendipity ;)
**
Y
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
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] hotmail com
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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |