POV-Ray : Newsgroups : povray.general : using eval_pigment--some questions before starting : Re: using eval_pigment--some questions before starting Server Time
30 Jul 2024 02:27:52 EDT (-0400)
  Re: using eval_pigment--some questions before starting  
From: Tim Attwood
Date: 8 Feb 2010 07:18:32
Message: <4b700118$1@news.povray.org>
> I call the first example a 'generic' vector, with no color information 
> attached.
> If I use a dot operation on it--like my_vector.y--it will (or should!) 
> give me
> just that component-- .8 --- as a simple single float value, AFAIK. If I 
> do the
> same with the 2nd example--which POV sees as a COLOR vector--then 
> my_vector.y
> will return <.8,.8,.8,.8,.8>---no longer a float but another 5-component 
> vector
> (described as one of the 'common color pitfalls' in the documentation, if 
> I
> understand it correctly.) If I don't 'correct' for this situation, it 
> could have
> unintended consequences later, depending on how I use my_vector.y
>
> SO...the real question I have is, does eval_pigment give me just
> <.1,.8,.5,.3,.4> or rgbft <.1,.8,.5,.3,.4>?

I think you are missunderstanding vector promotion and
extraction (demotion).

The color keyword (color, rgb, rgbft) triggers promotion of smaller
vectors and floats to the specified vector size. The dot operator
extracts one component as a float.

So
#local a=<0.1,0.8,0.5,0.3,0.4>.x;
is a float, where a == 0.1
but
#local a= rgbtf  <0.1,0.8,0.5,0.3,0.4>.x
is a 5D vector, where a == <0.1,0.1,0.1,0.1,0.1>
first the dot operator demotes the vector to a float,
then rgbtf  promotes it back to a 5D vector.

There is no type difference in POV between a
5D vector specified with color keywords or without.

Promotion of vectors makes for a nice shorthand...
Things like
translate 1.2*x
since x is a predefined vector <1,0,0> and
the 1.2 gets promoted to <1.2,1.2,1.2>, it ends up <1.2,0,0>
in this case a 3D vector. Vectors get promoted to the expected
levels... 5D for colors.


Post a reply to this message

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