|
|
clipka <ano### [at] anonymousorg> wrote:
> Am 03.12.2016 um 12:47 schrieb [GDS|Entropy]:
>
> > 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)
>
> I very much doubt that the latter works.
>
> As William already pointed out, the problem isn't so much the use of
> `Position`, or even `Position.x`, but the very first term of the
> expression inside `abs()`: The lone `x`.
>
> When standing on its own (as opposed to `Something.x`) outside of a
> function definition, `x` is a constant evaluating to `<1,0,0>`. Thus,
> the expression
>
> abs(x - Position.x)
>
> is equivalent to
>
> abs(<1,0,0> - Position.x)
>
> which, thanks to scalar-to-vector promotion, is in turn equivalent to
>
> abs(<1,0,0> - <Position.x,0,0>)
>
> which in turn is equivalent to
>
> abs(<1-Position.x,0,0>)
Clipka, I think you meant to write this:
which, thanks to scalar-to-vector promotion, is in turn equivalent to
abs(<1,0,0> - <Position.x, Position.x, Position.x>)
which in turn is equivalent to:
abs(<1 - Position.x, -Position.x, -Position.x>)
Ian, I suggest that you try this:
#declare Position = <9, 7, 5>;
#declare Result = x - Position.x;
#debug concat("\n\n<", vstr(3, Result, ", ", 0, -1), ">\n\n")
#error "To easier see the result"
Btw.: I wish POV-Ray had a "#stop" directive that didn't make so much fuss about
stopping. A directive that results in parsing only, without rendering, would be
great for code that is not written for the purpose of creating an image - which
I write a lot of.
--
Tor Olav
http://subcube.com
Post a reply to this message
|
|