POV-Ray : Newsgroups : povray.general : Macro assist? Server Time
6 Nov 2024 14:27:22 EST (-0500)
  Macro assist? (Message 1 to 4 of 4)  
From: Timothy R  Cook
Subject: Macro assist?
Date: 12 Aug 2002 03:36:11
Message: <3D57656A.1070600@scifi-fantasy.com>
Ok, I have a program in BASIC that I'm using to generate
random numbers for a sphere_sweep, that looks like:

randomize timer
for n=1 to 23
   theta%=(rnd*36)*20
   r = rnd*0.24
   x = r*COS(theta%)
   y = r*SIN(theta%)
   z = (rnd*0.5)+1.25
   ? USING "X = +#.#####  Y = +#.#####  Z = +#.#####";x,y,z
next n

now, instead of running this program and entering the
values by hand in my sphere_sweep, how do I make a
macro in POV to generate a series of n points for the
sphere_sweep?

-- 
Tim Cook
http://empyrean.scifi-fantasy.com
mirror: http://personal.lig.bellsouth.net/lig/z/9/z993126

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA dpu- s: a?-- C++(++++) U P? L E--- W++(+++)>$
N++ o? K- w(+) O? M-(--) V? PS+(+++) PE(--) Y(--)
PGP-(--) t* 5++>+++++ X+ R* tv+ b++(+++) DI
D++(---) G(++) e*>++ h+ !r--- !y--
------END GEEK CODE BLOCK------


Post a reply to this message

From: ABX
Subject: Re: Macro assist?
Date: 12 Aug 2002 03:51:30
Message: <eppelu09kja01hgcgq9uha0crolk5c90d1@4ax.com>
On Mon, 12 Aug 2002 03:36:10 -0400, "Timothy R. Cook"
<tim### [at] scifi-fantasycom> wrote:

> randomize timer

#declare Seed=seed(SeedNr);

> for n=1 to 23

#declare N=1;
#while(N<=23)

>     theta%=(rnd*36)*20

#declare Theta=rand(Seed)*36*20;

>     r = rnd*0.24

#declare R=rand(Seed)*24;

>     x = r*COS(theta%)

#declare X=R*cos(Theta);

>     y = r*SIN(theta%)

#declare Y=R*sin(Theta);

>     z = (rnd*0.5)+1.25

#declare Z=rand(Seed)*0.5+1.25;

>     ? USING "X = +#.#####  Y = +#.#####  Z = +#.#####";x,y,z

#debug concat(
         "  X = ",str(X,0,-1),
         "  Y = ",str(Y,0,-1),
         "  Z = ",str(Z,0,-1),
       "\n")

> next n

#declare N=N+1;
#end

Is it readable and sufficient or do you need some addition ?

ABX


Post a reply to this message

From: Timothy R  Cook
Subject: Re: Macro assist?
Date: 12 Aug 2002 04:02:30
Message: <3D576B93.8070000@scifi-fantasy.com>
ABX wrote:
> Is it readable and sufficient or do you need some addition ?

Should work...let's see...wow, I made a typo; that was 36*10,
not 36*20...but I can change it to 360...yep, this works fine.
Thanks!

-- 
Tim Cook
http://empyrean.scifi-fantasy.com
mirror: http://personal.lig.bellsouth.net/lig/z/9/z993126

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA dpu- s: a?-- C++(++++) U P? L E--- W++(+++)>$
N++ o? K- w(+) O? M-(--) V? PS+(+++) PE(--) Y(--)
PGP-(--) t* 5++>+++++ X+ R* tv+ b++(+++) DI
D++(---) G(++) e*>++ h+ !r--- !y--
------END GEEK CODE BLOCK------


Post a reply to this message

From: Bonsai
Subject: Re: Macro assist?
Date: 12 Aug 2002 04:14:19
Message: <3D576DBE.9080806@b0n541.net>
Timothy R. Cook schrieb:
> Ok, I have a program in BASIC that I'm using to generate
> random numbers for a sphere_sweep, that looks like:
> 
> randomize timer
> for n=1 to 23
>   theta%=(rnd*36)*20
>   r = rnd*0.24
>   x = r*COS(theta%)
>   y = r*SIN(theta%)
>   z = (rnd*0.5)+1.25
>   ? USING "X = +#.#####  Y = +#.#####  Z = +#.#####";x,y,z
> next n

I don't know BASIC very well, so maybe I changed the formulas a bit. But 
this is a fast hack for a macro:

#macro makeASphereSweep(numberOfPoints, splineType, startSeedValue)
	sphere_sweep
	  {
	  #switch (splineType)
                 #case (1)
		  linear_spline
   		#break
   		#case (2)
		  b_spline
   		#break
   		#case (3)
   		  cubic_spline
   		#break
		#else
		  linear_spline
		#end
	
	  numberOfPoints, // No. of spheres
	
	  #declare random = seed(startSeedValue);
	  #declare n = 0;
	  #while (n < numberOfPoints)
	    #declare theta = (rand(random) * 36) * 20;
	    #declare r = rand(random) * 0.24;
	    #declare x_val = r * cos(theta);
	    #declare y_val = r * sin(theta);
	    #declare z_val = (rand(random) * 0.5) + 1.25;
	    #if (n < numberOfPoints - 1)
	      <x_val, y_val, z_val>, r,
	    #else
	      <x_val, y_val, z_val>, r
	    #end
	    #declare n = n + 1;
	  #end
	
		pigment
			{
			color rgb 1
			}
	  }
#end

And then call your macro with:

makeASphereSweep(50, 1, 123)

Hope that helps a bit...

So long,

Bonsai


-- 
<--------------------------->
    ___ __ __  _ ___ ___  _
   | _ )  \  \( )  _) _ )( )
   | _ \() |\ \ |\ \/ _ \| |
   |___/__/_)\__)___)/ \_)_)

        www.b0n541.net
<--------------------------->


Post a reply to this message

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