POV-Ray : Newsgroups : povray.advanced-users : Q: Advanced Server Time
2 Nov 2024 15:23:41 EDT (-0400)
  Q: Advanced (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: Ken
Subject: Q: Advanced
Date: 18 Apr 1999 00:05:58
Message: <37194AB7.22B37382@pacbell.net>
When designing macros I have seen occassions where the macro was
specified like this example shows:

 #macro Pattern ()
      granite
        color_map{
                  [0.5000 rgb 0]
                  [0.5001 rgb 1]
                 }
            warp { turbulence .03 lambda 1.4 omega 2.0 octaves 5 }
       translate z*3
    scale <2, .5, 2>
  #end

 Note the absence of any identifiers inside the macro parenthesis ( )
 This was later used in a media statement as a density pattern.

  My question then is this. Why go through the trouble of making a macro
with no customizable attributes, for a one time use, when is would seem to
me that a simple #declared density would serve the same purpose.

  From where I sit there is no real difference from the above example
and the one that follows.

 #declare Pattern =
  density {
      granite
        color_map{
                  [0.5000 rgb 0]
                  [0.5001 rgb 1]
                 }
            warp { turbulence .03 lambda 1.4 omega 2.0 octaves 5 }
       translate z*3
    scale <2, .5, 2>
  }

  Would they not function the same way and is there anything to suggest
that the macro offers any advantage the way it is illustrated above ?



--
Ken

mailto://tylereng@pacbell.net


Post a reply to this message

From: TonyB
Subject: Re: Q: Advanced
Date: 18 Apr 1999 00:17:42
Message: <371941A7.B9834CB7@panama.phoenix.net>
I see it as a matter of taste and style, not really any advantage one has over
another. But, I suppose the logical benefit would be that instead of writing
"density {MyDensity}", you just write "MyDensity()" saving a whole 8
characters. At least that's the only reason I see for it.


Post a reply to this message

From: Johannes Hubert
Subject: Re: Q: Advanced
Date: 18 Apr 1999 05:57:43
Message: <37199e87.0@news.povray.org>
Semantically I don't see a difference either.

Is there a difference in which one parses faster?

Johannes.


Post a reply to this message

From: Ken
Subject: Re: Q: Advanced
Date: 18 Apr 1999 06:02:39
Message: <37199E53.73A88A26@pacbell.net>
Johannes Hubert wrote:
> 
> Semantically I don't see a difference either.
> 
> Is there a difference in which one parses faster?
> 
> Johannes.

Untested. No data available.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Margus Ramst
Subject: Re: Advanced
Date: 18 Apr 1999 09:04:20
Message: <3719ca44.0@news.povray.org>
The reason would be that you can use this in a pigment or a density, whereas
by #declaring you would be restricted to one of the two.

You can't do this:

#declare Pattern=pigment{...}
media{density{Pattern}}

or vice versa.

Margus

Ken wrote in message <37194AB7.22B37382@pacbell.net>...
>When designing macros I have seen occassions where the macro was
>specified like this example shows:
>
> #macro Pattern ()
>      granite
>        color_map{
>                  [0.5000 rgb 0]
>                  [0.5001 rgb 1]
>                 }
>            warp { turbulence .03 lambda 1.4 omega 2.0 octaves 5 }
>       translate z*3
>    scale <2, .5, 2>
>  #end
>
> Note the absence of any identifiers inside the macro parenthesis ( )
> This was later used in a media statement as a density pattern.
>
>  My question then is this. Why go through the trouble of making a macro
>with no customizable attributes, for a one time use, when is would seem to
>me that a simple #declared density would serve the same purpose.
>
>  From where I sit there is no real difference from the above example
>and the one that follows.
>
> #declare Pattern =
>  density {
>      granite
>        color_map{
>                  [0.5000 rgb 0]
>                  [0.5001 rgb 1]
>                 }
>            warp { turbulence .03 lambda 1.4 omega 2.0 octaves 5 }
>       translate z*3
>    scale <2, .5, 2>
>  }
>
>  Would they not function the same way and is there anything to suggest
>that the macro offers any advantage the way it is illustrated above ?
>
>
>
>--
>Ken
>
>mailto://tylereng@pacbell.net


Post a reply to this message

From: Ken
Subject: Re: Advanced
Date: 18 Apr 1999 09:21:08
Message: <3719CCD8.B56BD009@pacbell.net>
Margus Ramst wrote:
> 
> The reason would be that you can use this in a pigment or a density, whereas
> by #declaring you would be restricted to one of the two.
> 
> You can't do this:
> 
> #declare Pattern=pigment{...}
> media{density{Pattern}}
> 
> or vice versa.
> 
> Margus

 I will buy your argument where disallowed functions are concerned and
you will note I carefully avoided that trap with the second example I
provided. The reason I ask though comes from the fact that where I have
been observing the use of this macro peculiarity there have been only
one instance of the macro used in the file. No dual functionality was
apparent so the implementation seems out of place and quite frankly
unnecessary as well.

  Thank you for pointing out the potential duality for this and it is
worthy of taking note of for future use.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Margus Ramst
Subject: Re: Advanced
Date: 18 Apr 1999 10:20:42
Message: <3719dc2a.0@news.povray.org>
Well, it's the only argument I have. I suspect #macro is somewhat slower
than #declare. But since this is an issue in only some extreme cases, it
probably boils down to a matter of taste. Both give the same result with
roughly the same amount of typing, plus #macro has some added flexibility.
Perhaps the author made test renders with pigment instead of media. But this
is just unfounded speculation.

Margus

Ken wrote in message <3719CCD8.B56BD009@pacbell.net>...
>
> I will buy your argument where disallowed functions are concerned and
>you will note I carefully avoided that trap with the second example I
>provided. The reason I ask though comes from the fact that where I have
>been observing the use of this macro peculiarity there have been only
>one instance of the macro used in the file. No dual functionality was
>apparent so the implementation seems out of place and quite frankly
>unnecessary as well.
>
>  Thank you for pointing out the potential duality for this and it is
>worthy of taking note of for future use.
>
>--
>Ken Tyler
>
>mailto://tylereng@pacbell.net


Post a reply to this message

From: Spider
Subject: Re: Q: Advanced
Date: 18 Apr 1999 13:15:13
Message: <3719E593.4AF06868@bahnhof.se>
THe #declare _should_ parse faster, since there is no need to jump in the file.
I won't stand for it, and if you ask me, i wasn't sending this message :-)

I think there is a memory-difference as well, esp. when using several objects
with the same density(in this case)

Johannes Hubert wrote:
> 
> Semantically I don't see a difference either.
> 
> Is there a difference in which one parses faster?
> 
> Johannes.

-- 
//Spider
        [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
What I can do and what I could do, I just don't know anymore
                "Marian"
        By: "Sisters Of Mercy"


Post a reply to this message

From: Ronald L  Parker
Subject: Re: Q: Advanced
Date: 18 Apr 1999 19:16:08
Message: <371e5871.140247331@news.povray.org>
Hope I'm an advanced user...

On Sun, 18 Apr 1999 16:00:51 +0200, Spider <spi### [at] bahnhofse> wrote:

>THe #declare _should_ parse faster, since there is no need to jump in the file.
>I won't stand for it, and if you ask me, i wasn't sending this message :-)

I think so too.  Also, the #macro version actually has to read the
entire macro declaration once when the macro is first declared
(looking for the #end) as well as when it's invoked.

>I think there is a memory-difference as well, esp. when using several objects
>with the same density(in this case)

None that I know of.  In fact, the macro version might use slightly
less memory, but in either case it's a constant amount of memory used
and it won't grow if you use the declared object or macro more than
once.


Post a reply to this message

From: Rick
Subject: Re: Advanced
Date: 18 Apr 1999 19:16:35
Message: <371a59c3.0@news.povray.org>
well /\/\y "/\/\" key is knacked at the /\/\oment so personally i think
#declare is definatly faster for /\/\e.

(sorry couldn't help /\/\yself :)

Rick

Margus Ramst wrote in message <3719dc2a.0@news.povray.org>...
>Well, it's the only argument I have. I suspect #macro is somewhat slower
>than #declare. But since this is an issue in only some extreme cases, it
>probably boils down to a matter of taste. Both give the same result with
>roughly the same amount of typing, plus #macro has some added flexibility.
>Perhaps the author made test renders with pigment instead of media. But
this
>is just unfounded speculation.


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

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