POV-Ray : Newsgroups : povray.general : Vector identifiers/axis values in a float function : Re: Vector identifiers/axis values in a float function Server Time
26 Apr 2024 02:37:41 EDT (-0400)
  Re: Vector identifiers/axis values in a float function  
From: William F Pokorny
Date: 3 Dec 2016 09:51:30
Message: <5842dbf2$1@news.povray.org>
On 12/03/2016 06:47 AM, [GDS|Entropy] wrote:
> Hello,
>
> In a macro when I have a parameter of type vector and pass its value as
> such, I get an error:
>
> abs(x - Position.x)
>
> But if I do this it works:
>
> #local positionX = Position.x;
> abs(x - positionX)
>
> Why is this, and is there a way to do what I want to do?
>
> While abs is not a vector function the component part x is a float, right?
> So it seems like it should take it.
>
> It seems like there is either a parsing oversight, or that the axis values
> are not internally scalars, and as thus the local variable results in a
> cast or something that allows it to work.
>
> In the case of my macro the way I want to do this is cleaner than the other
> way in my opinion, as I an trying to cut down on the number of parameters
> in my macro and keep the local variables to a minimum.
>
> Thanks,
> Ian
>
I'm likely not following the "works vs not works" part of the story, but 
I think it the case 'x' is really shorthand for <1,0,0> inside POV-Ray 
and so abs() is going to see a vector expression for what you've written 
and not a float. This should be true in both cases you've outlined, but 
maybe I'm not seeing what makes this not so.

In other words 'x' is part of the SDL language denoting the x unit vector.

Use instead perhaps MyX and set it to 1 - or just use 1 and I think 
you'll be OK.

Bill P.


Post a reply to this message

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