|
 |
> (w.gray=0)
Since .gray multiplies each component by something, that might be slower
than something that merely adds the components together. Is there some other
vector property that merely gives the average of the three values?
(vlength(w) would probably work here, actually, without introducing the
problem that christopher brought up.)
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
 |
|
 |
In article <3d2e3aa8@news.povray.org>, "Slime" <slm### [at] slimeland com>
wrote:
> > (w.gray=0)
>
> Since .gray multiplies each component by something, that might be slower
> than something that merely adds the components together. Is there some other
> vector property that merely gives the average of the three values?
It is unlikely that it will make any noticeable difference, the overhead
of three multiplications is tiny compared to the CPU cost of parsing the
code.
And it would still reject valid input...the average component value of <
1, 2,-3> is the same as < 0, 0, 0>. It is unlikely to happen, but still
seems like a poor solution to me.
> (vlength(w) would probably work here, actually, without introducing the
> problem that christopher brought up.)
Computing the length requires 3 multiplications, 2 additions, and a call
to sqrt(). In C or C++, it would be slower than simply comparing each
component, but it might be faster than parsing the expression in POV. I
don't like it for general use because it doesn't say what it does...you
don't really care about the length, only whether or not the vector is <
0, 0, 0>...but it would probably be faster.
Another solution that I haven't seen anybody mention:
(!(V.x | V.y | V.z))
--
Christopher James Huff <chr### [at] mac com>
POV-Ray TAG e-mail: chr### [at] tag povray org
TAG web site: http://tag.povray.org/
Post a reply to this message
|
 |