POV-Ray : Newsgroups : povray.beta-test : Bug in image.c? Server Time
30 Jul 2024 16:18:36 EDT (-0400)
  Bug in image.c? (Message 1 to 1 of 1)  
From: R  Suzuki
Subject: Bug in image.c?
Date: 31 Oct 2001 01:19:18
Message: <3bdf97e6@news.povray.org>
I found a possible bug in image.c of V3.1g.
If this has been already fixed in V3.5, I am sorry for 
the posting.

The below C code is 'bilinear' function in image.c of V3.1g.
I think  the "if ((p == 0.0) && (q == 0.0)) {...}" was 
added in order to reduce the calculation time.
But the return value with the 'if' statement is different 
from the value without the statement in case p=0 and q=0.

The return value in the 'if' statement should be *(corners+3).

Or, it's better to remove the 'if' statement, because 
probability of the 'if' case is very small in usual interpolation
processes.

Same as 'norm_dist' function.

R. Suzuki

//-------------------------------------------------
static DBL bilinear(DBL *corners, DBL  x, DBL  y)
{
  DBL p, q;
  DBL val;

  p = x - (int)x;
  q = y - (int)y;

  if ((p == 0.0) && (q == 0.0))
  {
    return (*corners);  /* upper left */
  }

  val = (p * q * *corners) + (q * (1 - p) * *(corners + 1)) +
    (p * (1 - q) * *(corners + 2)) + ((1 - p) * (1 - q) * *(corners + 3));

  return (val);
}


Post a reply to this message

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