POV-Ray : Newsgroups : povray.general : Test for vector <0,0,0> : Re: Test for vector <0,0,0> Server Time
9 Aug 2024 01:26:34 EDT (-0400)
  Re: Test for vector <0,0,0>  
From: Jon A  Cruz
Date: 2 Sep 2000 10:30:25
Message: <39B10F99.5D686CA6@geocities.com>
Kevin Jackson-Mead wrote:

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

Almost, but....

As you can see, he used the abs, so those vectors you mentioned would turn into <2,
2, 0> and <3, 2, 5>, which would still pass his test.


Post a reply to this message

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