POV-Ray : Newsgroups : povray.newusers : Trig Troubles : Re: Trig Troubles Server Time
5 Sep 2024 10:30:53 EDT (-0400)
  Re: Trig Troubles  
From: Matthew Green
Date: 3 Mar 2001 15:34:25
Message: <3aa15551$1@news.povray.org>
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] yahoocom> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.