POV-Ray : Newsgroups : povray.bugreports : nan (not a number) Server Time
22 Nov 2024 23:30:32 EST (-0500)
  nan (not a number) (Message 1 to 6 of 6)  
From: Daniele Varrazzo
Subject: nan (not a number)
Date: 14 Apr 1999 11:35:50
Message: <3714a7c6.0@news.povray.org>
vnormalize (<0, 0, 0>) isn't matematically defined... but POV-Ray 3.1a
(windows) returns a "perfectly valid" <nan, nan, nan> vector... it's a sin
that there isn't any IsNan() function or something like that to recognize
it. And if i use this vector in any object the perser locks only while
creating light buffers.
I think vnormalize (<0, 0, 0>) should return an error in parsing time, and
POV should be compiled ignoring them.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: nan (not a number)
Date: 15 Apr 1999 14:06:04
Message: <37161c7c.0@news.povray.org>
In article <3714a7c6.0@news.povray.org> , "Daniele Varrazzo" <piro at 
officine dot it> wrote:

> vnormalize (<0, 0, 0>) isn't matematically defined... but POV-Ray 3.1a
> (windows) returns a "perfectly valid" <nan, nan, nan> vector... it's a sin
> that there isn't any IsNan() function or something like that to recognize
> it.

There is!

#declare myvector = <0,0,0>

#if((myvector.x == 0) && (myvector.y == 0) && (myvector.z == 0))
#error "Error"
#endif


     Thorsten


Post a reply to this message

From: Nieminen Mika
Subject: Re: nan (not a number)
Date: 15 Apr 1999 14:16:56
Message: <37161f08.0@news.povray.org>
In povray.general "Daniele Varrazzo" <piro at officine dot it> wrote:
: vnormalize (<0, 0, 0>) isn't matematically defined... but POV-Ray 3.1a
: (windows) returns a "perfectly valid" <nan, nan, nan> vector... it's a sin
: that there isn't any IsNan() function or something like that to recognize
: it.

  I think that's because it's system dependant. Recognizing NaN-values
would make it non-portable.
  In many systems this kind of mathematical operation will just crash
the program.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Spider
Subject: Re: nan (not a number)
Date: 15 Apr 1999 14:28:18
Message: <3716206F.6441B288@bahnhof.se>
Why not do something like this ?

#macro vnorm(vV)
  #if(vV=<0,0,0>)
    (<0,0,0>)
  #else
    vnormalize(vV)
  #end
#end

Daniele Varrazzo wrote:
> 
> vnormalize (<0, 0, 0>) isn't matematically defined... but POV-Ray 3.1a
> (windows) returns a "perfectly valid" <nan, nan, nan> vector... it's a sin
> that there isn't any IsNan() function or something like that to recognize
> it. And if i use this vector in any object the perser locks only while
> creating light buffers.
> I think vnormalize (<0, 0, 0>) should return an error in parsing time, and
> POV should be compiled ignoring them.

-- 
//Spider
        [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
What I can do and what I could do, I just don't know anymore
                "Marian"
        By: "Sisters Of Mercy"


Post a reply to this message

From: Spider
Subject: Re: nan (not a number)
Date: 15 Apr 1999 14:37:48
Message: <371622D0.8439421C@bahnhof.se>
or even better.
#macro vnorm(vV)
  #if(vV=<0,0,0>)
    #error "Normalize of <0,0,0>"
  #else
    vnormalize(vV)
  #end
#end

Spider wrote:
> 
> Why not do something like this ?
> 
> #macro vnorm(vV)
>   #if(vV=<0,0,0>)
>     (<0,0,0>)
>   #else
>     vnormalize(vV)
>   #end
> #end
> 
> Daniele Varrazzo wrote:
> >
> > vnormalize (<0, 0, 0>) isn't matematically defined... but POV-Ray 3.1a
> > (windows) returns a "perfectly valid" <nan, nan, nan> vector... it's a sin
> > that there isn't any IsNan() function or something like that to recognize
> > it. And if i use this vector in any object the perser locks only while
> > creating light buffers.
> > I think vnormalize (<0, 0, 0>) should return an error in parsing time, and
> > POV should be compiled ignoring them.
> 
> --
> //Spider
>         [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
> What I can do and what I could do, I just don't know anymore
>                 "Marian"
>         By: "Sisters Of Mercy"

-- 
//Spider
        [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
What I can do and what I could do, I just don't know anymore
                "Marian"
        By: "Sisters Of Mercy"


Post a reply to this message

From: Daniele Varrazzo
Subject: Re: nan (not a number)
Date: 16 Apr 1999 04:15:00
Message: <3716e374.0@news.povray.org>
>  I think that's because it's system dependant. Recognizing NaN-values
>would make it non-portable.
I know it... i don't want an IsNan: i'd like that vnormalize(<0,0,0>) should
always return an error, just like sqrt(-1). So it should 1/0 or 0/0 (that
are two very different things).

I know that nan is compiler-dependant. That's why none of the compiler
should admit it!

All the system such as #if (vV=<0,0,0>) are all nice systems to avoid
troubles... but are SLOW because a POV-Ray scene is not a compiled and
optimized language, but just parsed-on-the-fly code. The parser should make
all the controls it needs to render a proper scene and leave the user no
chance but a renderable code.

Povray cries loud if i access the tenth element of a 5 elements array... i
(matematically) cry louder if somebody ask me the direction of a zero length
vector!

I never used a nan-able compiler, but i think enabling it is just a compiler
option, such out of bound array controls or something else. Can't it be
disabled?
Daniele.


Post a reply to this message

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