POV-Ray : Newsgroups : povray.general : Rounding object : Re: Rounding object Server Time
6 Aug 2024 06:22:01 EDT (-0400)
  Re: Rounding object  
From: Christopher James Huff
Date: 12 Jul 2002 13:19:28
Message: <chrishuff-1D648F.12163912072002@netplex.aussie.org>
In article <3d2e3aa8@news.povray.org>, "Slime" <slm### [at] slimelandcom> 
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] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

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