POV-Ray : Newsgroups : povray.advanced-users : How to address last 2 components of 5-component vectors? : Re: How to address last 2 components of 5-component vectors? Server Time
3 May 2024 15:49:29 EDT (-0400)
  Re: How to address last 2 components of 5-component vectors?  
From: William F Pokorny
Date: 10 Jul 2016 14:32:39
Message: <578294c7$1@news.povray.org>
On 07/10/2016 12:32 PM, Le_Forgeron wrote:
> Le 10/07/2016 17:49, William F Pokorny a écrit :
>> On 07/10/2016 11:30 AM, William F Pokorny wrote:
>>> On 07/10/2016 08:37 AM, Le_Forgeron wrote:
>> ...
>>> OK. If the optionality is what we are trying to indicate, I think we
>>> probably want something like :
>>>
>>> COLOR_VECTOR:
>>>        [rgb] float            | (promoted to 3 value vector)
>>>        [rg0] <2 Term Vector>  |
>>>        [rgb] <3_Term_Vector>  |
>>>        [rgbf] <4_Term_Vector> |
>>>        rgbt <4_Term_Vector>   |
>>>        [ rgbft ] <5_Term_Vector> |
>>>        srgb <3_Term_Vector>   |
>>>        srgbf <4_Term_Vector>  |
>>>        srgbt <4_Term_Vector>  |
>>>        srgbft <5_Term_Vector>
>>>
>>> Bill P.
>>
>> Argh... Just popped into my head the line:
>>
>> [rg0] <2 Term Vector>  |
>>
>> is more like:
>>
>> [rgb] <2 Term Vector>  | (blue is zero in this case)
>>
>> there is of course no "rg0". :-)
>>
>> Bill P.
>
> IMHO, you are missing that, at another level, the missing terms are automatically
created from existing input when needed.
>
> float get promoted to 3D, 2D get completed to 3D with 0 as the last term and so on
(including 2D expended to 4D and 5D when needed)... but some too-short expression can
give you a warning (such as "Suspicious expression after rgbf.")
> On the same line, providing a 5D for a 4D (e.g. rgbf) will also give you a warning
(that's not a promotion/extension, rather a reduction).
> Yet, it is valid syntax. (even if the 5th term get ignored).
>
> On the same line, when "<N_Term_Vector>" is used, it can be any expression
(including +,-,* and /... and even some within ?: ternary operator ) which result in
such values, at the end.
> You are going to have very hard to have a readable syntax if you want to list all
possible cases for just "rgb xxxxx"
>
(Christoph, I saw your response too, but will respond just here)

I think I generally understand the promotion and demotion going on when 
colors are expected and we have various floats or vectors as the 
starting point/right-hand-argument.

When I originally questioned the line:

[ rgbft ] <5_Term_Vector> |

it was because our saying rgbft was optional per the brackets in just 
the five term vector case did not make sense to me for a syntax 
specification.

That "...the missing terms are automatically created from existing input 
when needed" is the point.

The rgb string is also optional for a float and multiple vector 
specifications. Why is it we are not showing the user it is optional 
with brackets as in [rgb], but doing it for rgbft and the 5 term vector 
case?

It seems to me for a syntax specification for color vectors we should be 
completely truthful about whether the string is optional, or always 
vague, listing just the various ".rgb.." strings.

Bill P.


Post a reply to this message

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