POV-Ray : Newsgroups : povray.programming : Bicubic patch bug (job000202) : Re: Bicubic patch bug (job000202) Server Time
28 Jul 2024 06:15:46 EDT (-0400)
  Re: Bicubic patch bug (job000202)  
From: Massimo Valentini
Date: 5 Nov 2002 12:14:41
Message: <3dc7fc81@news.povray.org>
"Safari" ha scritto 
: > 
: >||a||^2 > BEZIER_EPSILON * ||b||^2 * ||c||^2
: > 
: > and the image produced is quite independent from the scale factor.
: > 
: > HTH Massimo
: 
: hmm..  can you provide patch against povray-3.50 bezier.cpp?
: 

Here it is.

Massimo

--- src/bezier.cpp.ex Tue Nov  5 17:44:32 2002
+++ src/bezier.cpp Tue Nov  5 17:44:32 2002
@@ -469,7 +469,9 @@
   
   VDot(t, N, N);
   
-  if (t > BEZIER_EPSILON)
+  DBL squared_u1 = VSumSqr(U1);
+  DBL squared_v1 = VSumSqr(V1);
+  if (t > BEZIER_EPSILON * squared_u1 * squared_v1)
   {
     t = 1.0 / sqrt(t);
     
@@ -520,9 +522,11 @@
 
   VCross(Result, V1, V2);
 
-  VLength(Length, Result);
+  Length = VSumSqr(Result);
+  DBL squared_v1 = VSumSqr(V1);
+  DBL squared_v2 = VSumSqr(V2);
 
-  if (Length < BEZIER_EPSILON)
+  if (Length <= BEZIER_EPSILON * squared_v1 * squared_v2)
   {
     Make_Vector(Result, 1.0, 0.0, 0.0);
 
@@ -532,6 +536,8 @@
   }
   else
   {
+    Length = sqrt(Length);
+   
     VInverseScale(Result, Result, Length);
 
     VDot(*d, Result, v1);
@@ -581,7 +587,9 @@
 
   VDot(d, B[2], B[2]);
 
-  if (d < BEZIER_EPSILON)
+  DBL squared_b0 = VSumSqr(B[0]);
+  DBL squared_b1 = VSumSqr(B[1]);
+  if (d <= BEZIER_EPSILON * squared_b1 * squared_b0)
   {
     return (0);
   }


Post a reply to this message

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