POV-Ray : Newsgroups : povray.advanced-users : Parse error: float expected but vector or color expression found. Server Time
26 Dec 2024 08:50:48 EST (-0500)
  Parse error: float expected but vector or color expression found. (Message 1 to 4 of 4)  
From: Leo80s
Subject: Parse error: float expected but vector or color expression found.
Date: 23 Jan 2006 04:25:00
Message: <web.43d49e378348ed5172071f7b0@news.povray.org>
Hello everybody,

In my .pov fil I've defined a function in this way:

#declare dist = function(x1,y1,z1,x2,y2,z2)
      { sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2) ) };
(I hope It's right !!!)

When I try to use this in the code (the framment is reported above)...

#macro W (k,X,Y,Z)
       #local
distanza=dist(X,Y,Z,coordinate[k][0],coordinate[k][1],coordinate[k][2]);
       #if (distanza<1.0E-7)
                #declare result=1;
       #else
                #declare numeratore=pos(raggi[k]-distanza);
                #declare denominatore=raggi[k]*distanza;
                #declare result= numeratore / denominatore;
       #end
       result
#end

.... I have an error like in subject...
can anybody help me, please?

PS: I think that perhaps parameter X,Y,Z are treated by pov-ray like
non-initializated identifiers...is it right?

Thanks
Leo


Post a reply to this message

From: Mike Williams
Subject: Re: Parse error: float expected but vector or color expression found.
Date: 23 Jan 2006 05:03:18
Message: <kt16EAA+lK1DFwZI@econym.demon.co.uk>
Wasn't it Leo80s who wrote:
>Hello everybody,
>
>In my .pov fil I've defined a function in this way:
>
>#declare dist = function(x1,y1,z1,x2,y2,z2)
>      { sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2) ) };
>(I hope It's right !!!)
>
>When I try to use this in the code (the framment is reported above)...
>
>#macro W (k,X,Y,Z)
>       #local
>distanza=dist(X,Y,Z,coordinate[k][0],coordinate[k][1],coordinate[k][2]);
>       #if (distanza<1.0E-7)
>                #declare result=1;
>       #else
>                #declare numeratore=pos(raggi[k]-distanza);
>                #declare denominatore=raggi[k]*distanza;
>                #declare result= numeratore / denominatore;
>       #end
>       result
>#end
>
>.... I have an error like in subject...
>can anybody help me, please?
>
>PS: I think that perhaps parameter X,Y,Z are treated by pov-ray like
>non-initializated identifiers...is it right?

There's nothing wrong with that code in itself, as long as everything it
uses are floats and not vectors. 

You'll get that error if X, or Y or Z are vectors
       or if coordinate[][] is an array of vectors
           because you can't use vectors in a user defined function

       or if raggi[] is an array of vectors
           because then denominatore would be a vector, and you can't
           divide by a vector

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Leo80s
Subject: Re: Parse error: float expected but vector or color expression found.
Date: 23 Jan 2006 05:30:00
Message: <web.43d4aed8afb56a7072071f7b0@news.povray.org>
> There's nothing wrong with that code in itself, as long as everything it
> uses are floats and not vectors.
>
> You'll get that error if X, or Y or Z are vectors

X,Y and Z is never defined...their first occourence is there:

isosurface {
        function { rbf(x,y,z) }
        ...
}

and rbf is defined in this way:

#macro rbf (X,Y,Z)
        #local i=0;
        #local result=0;

        calcola_w(X,Y,Z)
        ...
#end

in the body of calcola_w there was this function call:

#local
distanza=dist(X,Y,Z,coordinate[k][0],coordinate[k][1],coordinate[k][2]);

>        or if coordinate[][] is an array of vectors
>            because you can't use vectors in a user defined function
>
>        or if raggi[] is an array of vectors
>            because then denominatore would be a vector, and you can't
>            divide by a vector
>

coordinate and raggi is defined in this way:

#declare coordinate     = array [4524][3];
#declare raggi          = array [4524];

I hope I've explained my problem...X,Y,Z are used to construct an isosurface
using a function defined by myself...


Post a reply to this message

From: Leo80s
Subject: Re: Parse error: float expected but vector or color expression found.
Date: 23 Jan 2006 07:10:01
Message: <web.43d4c6b8afb56a7072071f7b0@news.povray.org>
ok.. I've downloaded source code and I've seen that use a user-defined
function tu build an isosurface it's quite difficult...
I've seen that if I write

isosurface {
        function { rbf(x,y,z) }
        ...
}

x,y and z are not simple identifiers but are something like vectors...
In the source code (fnintern.cpp) I've seen that internal function povided
by povray has a sintax like this:

DBL f_torus(DBL *ptr, unsigned int) // 70
{
 PARAM_X = sqrt(PARAM_X * PARAM_X + PARAM_Z * PARAM_Z) - PARAM(0);
 return -PARAM(1) + sqrt(PARAM_X * PARAM_X + PARAM_Y * PARAM_Y);
}

how can I define a function (my rbf function in previous message..) in a way
like this to be able to use this function to build an isosurface???

sorry for my atrocious english, but It's very important to be able to do
this for my graduate thesis

Thanks
Leo


Post a reply to this message

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