POV-Ray : Newsgroups : povray.advanced-users : Vector components to function in isosurface Server Time
28 Jul 2024 18:22:25 EDT (-0400)
  Vector components to function in isosurface (Message 1 to 5 of 5)  
From: Mikael Pohjola
Subject: Vector components to function in isosurface
Date: 28 Jan 2004 09:39:20
Message: <opr2hpnwsx0x9foi@news.povray.org>
I tried to use a component from a vector and pass it to a function in an 
isosurface, and the parser returned an error. Se minimal scene below. The 
parser seems to confuse the notations k.u (component of a vector) and x 
(variable for the isosurface). Is this a "feature" or a bug? Or have I 
misunderstood something?

***Minimal scene***
#declare Function = function(u, v) {u*v}
#declare k = <1, 1>;

isosurface {
	function {y-Function(k.v*x, k.u*z)}
}

***Output***
isosurface {

function {y-Function(k <----ERROR

Parse Error: Expected 'operand', uv vector identifier found instead

Returned from renderer with error status

***

The workaround I figured out was to declare the vector components to 
variables:
#declare ku = k.u;
#declare kv = k.v;

and then everything works fine:
isosurface {
	function {y-Function(kv*x, ku*z)}
}

-- 
light_source{20*y,1}#macro _(M,X,Y,P)#macro L(N,D)#if(N)#declare 
P=P+D;box{-
0.5,0.5translate z*mod(9*P.gray,4)pigment{rgb P}rotate 45*x+clock*y 
translate
P}L(N-1,D)#end#end#if(M)L(mod(M,8)<mod(X,3)mod(Y,3)1>-1)_(div(M,8)div(X,3)div
(Y,3)P)#end#end _(2301603551,12850,60365,20*z-5*x)plane{y,-9pigment{rgb 1}}


Post a reply to this message

From: ABX
Subject: Re: Vector components to function in isosurface
Date: 28 Jan 2004 09:55:41
Message: <04jf10p2q3s1puuun2c6u12u79unebdec1@4ax.com>
On Wed, 28 Jan 2004 16:39:22 +0200, Mikael Pohjola <emp### [at] cchutfi> wrote:
> I tried to use a component from a vector and pass it to a function in an 
> isosurface, and the parser returned an error. Se minimal scene below. The 
> parser seems to confuse the notations k.u (component of a vector) and x 
> (variable for the isosurface). Is this a "feature" or a bug? Or have I 
> misunderstood something?

Feature. Functions syntax has separated syntax description in manual.

> isosurface {
> 	function {y-Function(k.v*x, k.u*z)}
> }

You have to workaround it with additional float variables.

  function {
    #local kv = k.v;
    #local ku = k.u;
    y-Function(kv*x, ku*z)
  }

ABX


Post a reply to this message

From: Christoph Hormann
Subject: Re: Vector components to function in isosurface
Date: 28 Jan 2004 10:10:06
Message: <5lvke1-rlu.ln1@triton.imagico.de>
Mikael Pohjola wrote:
> I tried to use a component from a vector and pass it to a function in an 
> isosurface, and the parser returned an error. Se minimal scene below. 
> The parser seems to confuse the notations k.u (component of a vector) 
> and x (variable for the isosurface). Is this a "feature" or a bug? Or 
> have I misunderstood something?
> 

This is a feature, vectors are not allowed in user defined functions.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 11 Jan. 2004 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Mikael Pohjola
Subject: Re: Vector components to function in isosurface
Date: 29 Jan 2004 09:18:54
Message: <opr2jjdwem0x9foi@news.povray.org>
On Wed, 28 Jan 2004 16:04:37 +0100, Christoph Hormann 
<chr### [at] gmxde> wrote:

> Mikael Pohjola wrote:
>> I tried to use a component from a vector and pass it to a function in 
>> an isosurface, and the parser returned an error. Se minimal scene 
>> below. The parser seems to confuse the notations k.u (component of a 
>> vector) and x (variable for the isosurface). Is this a "feature" or a 
>> bug? Or have I misunderstood something?
>>
>
> This is a feature, vectors are not allowed in user defined functions.
>
> Christoph
>

Yes, I know that vectors are not allowed in user defined functions, but 
why are not vector components?
If V = <a, b, c>, then V.x does not return <a, 0, 0>, but a.
What is the difference with a component of a vector and a float? (I guess 
it have something to do with the parser and inner representation??)
I got my answer already from ABX, and I am happy with the workaround.

-- 
light_source{20*y,1}#macro _(M,X,Y,P)#macro L(N,D)#if(N)#declare 
P=P+D;box{-
0.5,0.5translate z*mod(9*P.gray,4)pigment{rgb P}rotate 45*x+clock*y 
translate
P}L(N-1,D)#end#end#if(M)L(mod(M,8)<mod(X,3)mod(Y,3)1>-1)_(div(M,8)div(X,3)div
(Y,3)P)#end#end _(2301603551,12850,60365,20*z-5*x)plane{y,-9pigment{rgb 1}}


Post a reply to this message

From: ABX
Subject: Re: Vector components to function in isosurface
Date: 29 Jan 2004 09:38:11
Message: <fa6i10tsferpa13179mlhe3gtfce2jicot@4ax.com>
On Thu, 29 Jan 2004 16:18:58 +0200, Mikael Pohjola <emp### [at] cchutfi> wrote:
> What is the difference with a component of a vector and a float?

Dot operator is reserved for access to components of vector/color functions.
Adjustement to vectors is not that simple there because function parser is
separated to the SDL parser. You have to remember that function code has (in
design) posibility to be precompiled int almost native machine code.

ABX


Post a reply to this message

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