POV-Ray : Newsgroups : povray.beta-test : More To Test : Re: More To Test Server Time
16 Apr 2024 03:52:24 EDT (-0400)
  Re: More To Test  
From: clipka
Date: 25 Nov 2016 11:21:25
Message: <58386505$1@news.povray.org>
Am 25.11.2016 um 16:30 schrieb Jim Holsenback:
> On 11/25/2016 10:21 AM, clipka wrote:
>> Am 25.11.2016 um 15:29 schrieb Jim Holsenback:
>>> Error: Bad operands for period operator.
>>>
>>> #local Pt1 = Vec + x*(OTO_Get_Offset(Vec).x) +
>>> y*(OTO_Get_Offset(Vec+x).y);
>>
>> Need more input -- what is OTO_Get_Offset(..)?
>>
> it's in sam's odd tiles marco ... attached is complete include

It's a bug in OTO_Get_Offset(), which had previously been lying somewhat
dormant, but has now been exposed.

The macro evaluates to something of the form

    V*S

where V is a vector expression and S is a scalar expression. It is used
in an expression of the form

    M().y

which evaluates to

    V*S.y

Since the dot operator binds stronger than the multiplication operator,
this should be equivalent to

    V*(S.y)

which is illegal, and has always been, since S only has a single dimension.

However, this was masked in earlier versions by an internal bug in
scalar-to-vector promotion (reported on GitHub as issue #130), which
caused POV-Ray to immediately promote S to a vector of the same
dimensions as V, when the correct behaviour should have been to first
evaluate (S.y) and then promote the result.


The proper solution would be to add more braces to the expression in
OTO_Get_Offset(), so that the macro expansion yields the proper desired
expression:

    (V*S).y


As a side note, the invoking statement is rather cumbersome, using an
expression of the form:

    x*(V1.x) + y*(V2.y)

This can easily be abbreviated to:

    x*V1 + y*V2

or

    <V1.x, V2.y>

(though the latter definitely requires the macro to be fixed).


Post a reply to this message

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