POV-Ray : Newsgroups : povray.bugreports : prism, linear spline, conic sweep bug : Re: prism, linear spline, conic sweep bug Server Time
18 Jun 2024 09:17:12 EDT (-0400)
  Re: prism, linear spline, conic sweep bug  
From: Darius Davis
Date: 17 Nov 1998 05:23:09
Message: <365140C9.2A9@acm.org>
Dan Connelly wrote:
> The listed script yields erronious results with or without
> the "open" keyword in the prism commented out.
> 
> What is expected is a closed truncated prism.  What is
> observed is an open truncated prism with a misplaced face.

Hi Dan & other readers,

I have found two bugs in the code for cubic sweep prisms - firstly, the
'open' parameter does not work, and secondly, there is a mistake in the
bounding calculations that is causing the appearance of faulty end-caps
on some shapes.

To make the 'open' parameter function, insert the following code (marked
'*') at line 534 of PRISM.C:


      else
      {
*       if (Test_Flag(Prism, CLOSED_FLAG))
*       {
          /* Intersect ray with the cap-plane. */

          k = (Prism->Height2 - P[Y]) / D[Y];

          if ((k > DEPTH_TOLERANCE) && (k < Max_Distance))


and close the braces at the appropriate place (after the base-plane
intersection test).  That's really a pretty trivial bug & fix (unless I
overlooked something...).

I have not yet found a 'clean' fix for the bounding problem, but it can
be bypassed by changing the following lines (marked "*") in function
"in_curve", PRISM.C line 1317:


       /* First test overall bounding rectangle. */

*     if (((u >= Prism->x1) && (u <= Prism->x2) &&
*         (v >= Prism->y1) && (v <= Prism->y2)) || (Prism->Sweep_Type ==
CONIC_SWEEP))
      {
        for (i = 0; i < Prism->Number; i++)
        {
          Entry = Prism->Spline->Entry[i];

          /* Test if current segment can be hit. */

*         if (((v >= Entry.y1) && (v <= Entry.y2) && (u <= Entry.x2))
*              || (Prism->Sweep_Type == CONIC_SWEEP))
          {


This will completely bypass bounds-checking for the end caps of conic
sweep prisms, which will probably degrade performance significantly, but
will produce the correct image.  I have determined the cause of this
problem, and I am still working on producing a better fix for this
problem.

For the interested (few, very few I'd say...) the bug is caused by the
following: When the end-caps of a conic spline are tested, POV-Ray
determines the point at which the ray intersects the plane of the
end-cap, and then determines the <u, v> coordinates (in the plane of the
defined spline) which this point represents and calls in_curve to
determine whether this point is within the end-cap.  The <u, v> value is
then erroneously compared against the calculated shape & segment bounds
for the conic sweep prism object itself rather than the bounds of the
*spline*, which are quite different.  This is the cause of the errors.

The problem is demonstrated by many conic_sweep prisms for which the
interval HEIGHT1..HEIGHT2 does not include the value +1.0

I will pass these fixes onto the POV-Team once I have found a better way
of fixing the bounds problem.

Cheers,

Darius Davis


Post a reply to this message

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