POV-Ray : Newsgroups : povray.general : Using x, y, and z values in a function. Server Time
5 Nov 2024 05:22:56 EST (-0500)
  Using x, y, and z values in a function. (Message 1 to 2 of 2)  
From: Serious Putty
Subject: Using x, y, and z values in a function.
Date: 6 Jul 2003 23:15:02
Message: <web.3f08e54f2a66c56848cb617a0@news.povray.org>
I've been trying to generate a new kind of pattern by use of macros and am
unable to use the individual coordinates of the point being evaluated for
the pattern.

This works:

#macro crn()
  (x - int(x))
#end

This does not:
#macro crn()
  #declare a = int(x);
  (x - a)
#end

Why?

What I want to do is get the x, y, and z values of the point being evaluated
by pigment{function{crn()} and use them as they were floats, not vectors.
I need them for array indices as my noise resembles Perlin in its
calculation, but uses a catmull-rom spline (smoother noise, more control
points) instead of cubic.

Some years ago I modified Povray source, swapping the internal noise
function for the catmull-rom version, but I could only compile in DOS.  I
tried to get it into MegaPov but the development of Povray 3.5 prevented
it.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Using x, y, and z values in a function.
Date: 7 Jul 2003 00:22:32
Message: <Xns93B141095B852torolavkhotmailcom@204.213.191.226>
"Serious Putty" <nomail@nomail> wrote in
news:web.3f08e54f2a66c56848cb617a0@news.povray.org: 

> I've been trying to generate a new kind of pattern by use of macros
> and am unable to use the individual coordinates of the point being
> evaluated for the pattern.
> 
> This works:
> 
> #macro crn()
>   (x - int(x))
> #end
> 
> This does not:
> #macro crn()
>   #declare a = int(x);
>   (x - a)
> #end
> 
> Why?
> 
> What I want to do is get the x, y, and z values of the point being
> evaluated by pigment{function{crn()} ...


Because macros are only executed at parse-time.

It also seems like you are trying to make some kind of local
variable for your function with the #declare a = int(x) statement.

But functions cannot have local variables.


Tor Olav


Post a reply to this message

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