POV-Ray : Newsgroups : povray.general : Tutorial for macros and arrays? Server Time
5 Nov 2024 03:16:11 EST (-0500)
  Tutorial for macros and arrays? (Message 1 to 6 of 6)  
From: David Etter Perere
Subject: Tutorial for macros and arrays?
Date: 7 Dec 1998 21:03:10
Message: <01be224e$e7f773e0$4e0e8dc3@default>
hello,

As I'm not programmer I did learn a lot reading Sonya Roberts's Rendering
Times POVabilities (http://www.spake.org/rtimes/article/povindx.htm). This
tutorial is really great for a guy like me using specially a modeller who
needs to discover more.

But since spring '98, this page didn't change. Now with the new features of
version 3.1 like arrays and macros, the doc of Povray is not enough clear
to help me to understand what means for exemple the scene files of the
excellent "Running" -winner in the last IRTC.

Well, does anybody knows about such tutorial on the net or anywhere else
(even better in french)?

Thank's
-- 
per### [at] bofinfomaniakch
remove the "bof." to answer


Post a reply to this message

From: Spider
Subject: Re: Tutorial for macros and arrays?
Date: 8 Dec 1998 06:57:36
Message: <366D138A.4820E9A0@bahnhof.se>
Hello.
The best way of learning macros are to use them.

#declare MyArray = array[5] {4,3,2,1,0}
That declares an array of 5 posts(0-4).

#macro MyMacro(param)
  sphere {
    <0,0,0>
    param
  }
#end

declares a macro. To use it, simply call MyMacro from inside a object {}(or any CSG)
statement.

object {
  MyMacro(0.5)
  pigment { colour rgb 1 }
}
It does not use the macro as an function, instead, it inserts the macro at every
statement, with the parameters defined as in the macro call. 

hope it helps,
//Spider


David Etter Perere wrote:
> 
> hello,
> 
> As I'm not programmer I did learn a lot reading Sonya Roberts's Rendering
> Times POVabilities (http://www.spake.org/rtimes/article/povindx.htm). This
> tutorial is really great for a guy like me using specially a modeller who
> needs to discover more.
> 
> But since spring '98, this page didn't change. Now with the new features of
> version 3.1 like arrays and macros, the doc of Povray is not enough clear
> to help me to understand what means for exemple the scene files of the
> excellent "Running" -winner in the last IRTC.
> 
> Well, does anybody knows about such tutorial on the net or anywhere else
> (even better in french)?
> 
> Thank's
> --
> per### [at] bofinfomaniakch
> remove the "bof." to answer


Post a reply to this message

From: David Etter Perere
Subject: Re: Tutorial for macros and arrays?
Date: 9 Dec 1998 16:09:47
Message: <01be23b8$3dcaad40$19108dc3@default>
Thank you Spider for your answer, but I'm located some prehistorics steps
before.

It's the purpose of arrays and macros that I don't understand. I suppose
that macros are something that permit to make a repetitive action, maybe a
bit like "#while x<y ... x=x+1 ..". But arrays? A line of numbers?

That is a very very basic question. That's why I became an addict of Sonya
Roberts's Rendering Times POVabilities. It helps me to read and change
thinks in Colefax .INC or in DGPAS.

About Sonya Roberts, does anybody knows what's going on?


<366D138A.4820E9A0@bahnhof.se>...
> Hello.
> The best way of learning macros are to use them.
>


Post a reply to this message

From: Spider
Subject: Re: Tutorial for macros and arrays?
Date: 9 Dec 1998 19:26:15
Message: <366F1480.B3EA743F@bahnhof.se>
Yes.
It is a easy way to access a seris of numbers/vectors or object, without coding it.
The way you make a vector, you can easily modify your code to accept more numbers.
You can always do :
#declare X1 = 1;
#declare X2 = 4;
#declare X3 = 5;
#declare X4 = 2;

But it is far more cumbersome to loop through that set of numbers(almost impossible)
than
if you do it :
#declare X = array[4] { 1,4,5,2 }

To add the first, you'd have to do :
#declare NX = X1+X2+X3+X4;

The second : 
#declare C=0;
#while (C< (dimension_size(X,1)))
  #declare NX=NX+X[C];
  #declare C=C-1;
#end

This might seem to be more code, but if you have, say 2000 sample points, you realise
why
the array is far better, even more so, if you want to COMPUTE the points before, from
say
a function f(i)=i^(i-1)+1/i 

There is one of the uses for an array. Another is that a macro doesn't need to know
the
exact number of parameters, it can find it out by itself. Why is tat so good then ???
Because that you can make it much more flexible.

I hope this enlightens a bit more...

I'm not a teacher, I'm programmer, I know I can go to fast ... :-)

//Spider


David Etter Perere wrote:
> 
> Thank you Spider for your answer, but I'm located some prehistorics steps
> before.
> 
> It's the purpose of arrays and macros that I don't understand. I suppose
> that macros are something that permit to make a repetitive action, maybe a
> bit like "#while x<y ... x=x+1 ..". But arrays? A line of numbers?
> 
> That is a very very basic question. That's why I became an addict of Sonya
> Roberts's Rendering Times POVabilities. It helps me to read and change
> thinks in Colefax .INC or in DGPAS.
> 
> About Sonya Roberts, does anybody knows what's going on?
> 

> <366D138A.4820E9A0@bahnhof.se>...
> > Hello.
> > The best way of learning macros are to use them.
> >


Post a reply to this message

From: Nieminen Mika
Subject: Re: Tutorial for macros and arrays?
Date: 10 Dec 1998 06:22:34
Message: <366faefa.0@news.povray.org>
David Etter Perere <per### [at] infomaniakch> wrote:
: It's the purpose of arrays and macros that I don't understand.

  Instead of making something like this:

#while(A<...)
  #while(B<...)
    #declare PosX=A
    #declare PosY=B
    #declare Height=#include "function.inc"
    sphere { <A,Height,B>,1 }
  ...

you can make this:

#while(A<...)
  #while(B<...)
    sphere { <A,function(A,B),B>,1 }
  ...

  'function' could also be an array instead of a macro.

-- 
main(i){char*_="BdsyFBThhHFBThhHFRz]NFTITQF|DJIFHQhhF";while(i=
*_++)for(;i>1;printf("%s",i-70?i&1?"[]":" ":(i=0,"\n")),i/=2);} /*- Warp. -*/


Post a reply to this message

From: David Etter Perere
Subject: Re: Tutorial for macros and arrays?
Date: 10 Dec 1998 20:53:16
Message: <01be24a8$ef8180e0$300e8dc3@default>
Thank's,

It's going to be much clearer. I'm going to meditate on your responses and
begin to play with that kind of features.



<366F1480.B3EA743F@bahnhof.se>...
> Yes.
> It is a easy way to access a seris of numbers/vectors or object, without
coding it.
> The way you make a vector, you can easily modify your code to accept more
numbers.
> ...
> I'm not a teacher, I'm programmer, I know I can go to fast ... :-)
> 
> //Spider


<366faefa.0@news.povray.org>...
> David Etter Perere <per### [at] infomaniakch> wrote:
> : It's the purpose of arrays and macros that I don't understand.
> 
>   Instead of making something like this:
>   ...
> 
>   'function' could also be an array instead of a macro.
> 
> -- 
> main(i){char*_="BdsyFBThhHFBThhHFRz]NFTITQF|DJIFHQhhF";while(i=
> *_++)for(;i>1;printf("%s",i-70?i&1?"[]":" ":(i=0,"\n")),i/=2);} /*- Warp.
-*/
>


Post a reply to this message

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