POV-Ray : Newsgroups : povray.general : Test for vector <0,0,0> : Re: Test for vector <0,0,0> Server Time
9 Aug 2024 01:22:07 EDT (-0400)
  Re: Test for vector <0,0,0>  
From: Kevin Jackson-Mead
Date: 2 Sep 2000 10:23:40
Message: <39B10CF1.42249F5C@mindspring.com>
Christoph Hormann wrote:

> 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 )
>

Maybe I'm missing something here, but this isn't going to work.  All you're doing
is adding up the vector components.  Yes, it will be true for the zero vector,
but it will also be true for vectors like <2, -2, 0> and <3, 2, -5>, etc.



>
> 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/

Kevin Jackson-Mead
http://www.mindspring.com/~jacksonmead


Post a reply to this message

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