POV-Ray : Newsgroups : povray.bugreports : Erroneous edge case trigonometric function values : Re: Erroneous edge case trigonometric function values Server Time
21 Oct 2025 11:11:23 EDT (-0400)
  Re: Erroneous edge case trigonometric function values  
From: Bald Eagle
Date: 20 Oct 2025 10:40:00
Message: <web.68f64949dc2f5cb9c330b87125979125@news.povray.org>
Cousin Ricky <ric### [at] yahoocom> wrote:
> On 2025-10-15 22:22 (-4), Bald Eagle wrote:
> >
> > It appears that at 90 degrees (pi/2), tan and sec do not equal Inf.
> > so
> > #declare csc = function (N) {select (sin(N), 1/sin(N), Inf, 1/sin(N))}
> > failed.
> > I had to test against 1E10.
>
> This isn't so much a bug as a floating point limitation.  Pi/2 has no
> exact representation in binary, so you never get exactly 90 degrees.

I managed to code some macros for all of the trig functions that seems to work
well for increments as small as pi/180.

It seems to me that we ought to have code that works out of the box for at least
1-degree increments.

I'll have to look in the source code to see what we use to store the values - it
would probably be nice to use double or extended precision of some sort.

- BW


Post a reply to this message

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