POV-Ray : Newsgroups : povray.bugreports : inside() results in: Parse Error: Expected 'operand', object identifier, found instead : Re: inside() results in: Parse Error: Expected 'operand',objectidentifier, = Server Time
7 Jun 2025 12:30:58 EDT (-0400)
  Re: inside() results in: Parse Error: Expected 'operand',objectidentifier, =  
From: William F Pokorny
Date: 31 May 2025 14:09:05
Message: <683b45c1$1@news.povray.org>
On 5/31/25 06:10, Kenneth wrote:
> But can the V vector here still be used in some way-- with the object
> *function*-- to determine if that particular point is inside/outside? (I admit
> that I have trouble understanding some of the subtleties and limitations of
> function use.)

As always, a good job asking deeper questions, Kenneth. :-)

In the function{} body context we cannot use vectors(*) which means 
there are some situations, like function{} block use in pigment{} blocks 
where we must - in the parser, parse-time, context - escape the 
function{} body context in ugly-ish ways to access vectors over time.

Hopefully the updated SDL is of more help.

//---
#version 3.7;

#declare V = <1,2,3>;
#declare OBJ = torus { 5,1 }

//  #declare F = function { inside(OBJ, V) }
     #declare F = function { pattern { bool_object { OBJ } } }
     #declare F_inside = function { pattern { bool_object { OBJ } } }

     #declare ValZeroOROne = F(V.x,V.y,V.z);
//  #if (ValZeroOROne=0)
     #if (!F(V.x,V.y,V.z))
         #declare AnsStr = "outside"
     #else
         #declare AnsStr = "inside"
     #end

     #declare Vx = V.x;
     #declare Vy = V.y;
     #declare Vz = V.z;
//  #declare F2 = function { F(V.x,V.y,V.z) } // Illegal.
     #declare F2 = function { F(Vx,Vy,Vz) }    // OK

     #declare F3 = function (x,y,z) {
         // Ugly way to fixed, parse time float arguments
         // in a function{} block context
         F(#local X=V.x;X*x, #local Y=V.y; Y*y, #local Z=V.y;Z*z)
         #undef X #undef Y #undef Z
     }

     #declare F4 = function (x,y,z,X,Y,Z) {
         F(X*x,Y*y,Z*z)
     }

     #declare tmpVal = F(V.x,V.y,V.z);        // OK
     #declare tmpVal = F_inside(V.x,V.y,V.z); // OK  (**)
     #declare tmpVal = F4(V.x,V.y,V.z,1,1,1); // OK
     #declare tmpVal = F4(1,1,1,V.x,V.y,V.z); // OK

plane { -z, 0
//  pigment { function { F(x,y,z) } }
//  pigment { function { F2(x,y,z) } }
     pigment {
         function { // Ugly way to parse time-fixed, function
                    // context, float arguments
             F(#local X=V.x;X,
               #local Y=V.y;Y,
               #local Z=V.y;Z) #undef X #undef Y #undef Z
         }
     }
     finish { emission 1 }
}
#declare Cam = camera {}
camera { Cam translate -20*z}

#debug concat ("==> The test point V is ",AnsStr," <==\n")

Bill P.

(*) The yuqk fork implemented a limited ability to use 32bit 2D vectors 
and 21bit 3D vectors by encoding them in the 64bit float space the VM 
function mechanism supports, but that's more of a FWIW thing.

(**) A long time ago I ran across some SDL which defined an Inside() 
user function which was essentially F_inside(). If others saw this too, 
or mention of it exists somewhere in the forums etc., it might be 
contributing some to the confusion.


Post a reply to this message

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