POV-Ray : Newsgroups : povray.general : Test for vector <0,0,0> : Re: Test for vector <0,0,0> Server Time
9 Aug 2024 01:25:26 EDT (-0400)
  Re: Test for vector <0,0,0>  
From: Christoph Hormann
Date: 2 Sep 2000 08:40:13
Message: <39B0F580.685093C0@schunter.etc.tu-bs.de>
Rune wrote:
> 
> I see many people use
> 
> #if ( Vector.x=0 & Vector.y=0 & Vector.z=0 )
> and
> #if ( Vector.x!=0 & Vector.y!=0 & Vector.z!=0 )
> 
> I personally find it much simpler to use
> 
> #if (vlength(Vector)=0)
> and
> #if (vlength(Vector)!=0)
> 
> I just thought I'd share it with you.
> 
> Rune

If you consider speed optimization, how about:

#if ( abs(Vector.x)+abs(Vector.y)+abs(Vector.z)=0 )

I don't know how fast povray calculates vlength(), but in regular programming
this would probably be faster, because vlength() would have to use
multiplication and sqrt().  

Christoph

--
Christoph Hormann <chr### [at] gmxde>
Homepage: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

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