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