POV-Ray : Newsgroups : povray.general : sphere_sweep bug workaround needed Server Time
5 Nov 2024 05:20:53 EST (-0500)
  sphere_sweep bug workaround needed (Message 1 to 5 of 5)  
From: Rune
Subject: sphere_sweep bug workaround needed
Date: 24 Aug 2007 19:44:05
Message: <46cf6d45$1@news.povray.org>
I'm having a problem with a sphere-sweep that looks like the bounding box is 
too small: some of it is not shown. It's not related to the tolerance 
setting or self-shadowing, nor seem it to be a precision problem, as scaling 
it all larger or smaller makes no difference. I also tried to apply my own 
larger bounding_box, but it makes no difference. Any pointers what I can do?

Minimal scene:


#declare FlowerAlignments = array[3]
{1.24*<1,1,1>, <-65,  5,-50>, <8.1,-7.8,30>},

union {
   #declare C = 0;
   #while (C<6)
      sphere_sweep {
         cubic_spline 4,
         <0,-6.0,0.00>, 0.12,
         <0,-0.2,0.07>, 0.05,
         <0, 2.1,0.70>, 0.01,
         <0, 2.5,2.50>, 0.00
         /*bounded_by {box {
            <-0.05,-0.25,0.02>-<1,1,1>,
            <0.05,2.11,0.71>+<1,1,1>
         }}*/ // no difference
         rotate 60*y*C
      }
      #declare C = C+1;
   #end
   pigment {rgb <1.50,0.90,0.00>}
   translate -y
   scale FlowerAlignments[0]
   rotate FlowerAlignments[1]*<0,1,0>
   rotate FlowerAlignments[1]*<1,0,1>
   translate FlowerAlignments[2]
}

camera {
   location -FlowerAlignments[2]
   look_at 0
   angle FlowerAlignments[0].x*5
   translate FlowerAlignments[2]
}

light_source {< 1, 2,-3>*1000, rgb 1.0}
light_source {<-3, 1,-2>*1000, rgb 0.6}
light_source {<-1,-3,-2>*1000, rgb 0.6}


Rune
-- 
http://runevision.com


Post a reply to this message

From: Tim Attwood
Subject: Re: sphere_sweep bug workaround needed
Date: 24 Aug 2007 21:31:16
Message: <46cf8664$1@news.povray.org>
> I'm having a problem with a sphere-sweep that looks like the bounding box 
> is too small: some of it is not shown. It's not related to the tolerance 
> setting or self-shadowing, nor seem it to be a precision problem, as 
> scaling it all larger or smaller makes no difference. I also tried to 
> apply my own larger bounding_box, but it makes no difference. Any pointers 
> what I can do?

Yeah, sphere_sweeps are bugged.  I wish they weren't.
I'd use a macro...

#macro Sweep(SPL, from, to, rez)
 #local eval_to = to;
 #local C = from;
 sphere {<SPL(C).x,SPL(C).y,SPL(C).z>,SPL(C).t}
 #while (C<eval_to-rez)
  cone {<SPL(C).x,SPL(C).y,SPL(C).z>,SPL(C).t,
  <SPL(C+rez).x,SPL(C+rez).y,SPL(C+rez).z>,SPL(C+rez).t}
  sphere {<SPL(C+rez).x,SPL(C+rez).y,SPL(C+rez).z>,
    SPL(C+rez).t}
  #local C=C+rez;
 #end
#end

#declare Foo = spline {
   cubic_spline
   -0.33, <0, -6.0, 0.00, 0.12  >,
    0.00, <0, -6.0, 0.00, 0.12  >,
    0.33, <0, -0.2, 0.07, 0.05  >,
    0.66, <0,  2.1, 0.70, 0.01  >,
    1.00, <0,  2.5, 2.50, 0.0001>,
    1.33, <0,  2.5, 2.50, 0.0001>
};

#declare Bar = union {Sweep(Foo, 0, 1, 0.01)};

#declare FlowerAlignments = array[3]
{1.24*<1,1,1>, <-65,  5,-50>, <8.1,-7.8,30>},

union {
   #declare C = 0;
   #while (C<6)
      object { Bar
         rotate 60*y*C
      }
      #declare C = C+1;
   #end
   pigment {rgb <1.50,0.90,0.00>}
   translate -y
   scale FlowerAlignments[0]
   rotate FlowerAlignments[1]*<0,1,0>
   rotate FlowerAlignments[1]*<1,0,1>
   translate FlowerAlignments[2]
}

camera {
   location -FlowerAlignments[2]
   look_at 0
   angle FlowerAlignments[0].x*5
   translate FlowerAlignments[2]
}
light_source {< 1, 2,-3>*1000, rgb 1.0}
light_source {<-3, 1,-2>*1000, rgb 0.6}
light_source {<-1,-3,-2>*1000, rgb 0.6}


Post a reply to this message

From: Rune
Subject: Re: sphere_sweep bug workaround needed
Date: 24 Aug 2007 21:39:42
Message: <46cf885e$1@news.povray.org>
Tim Attwood wrote:
> Yeah, sphere_sweeps are bugged.  I wish they weren't.
> I'd use a macro...

Yeah, I might end up doing that.

By the way, when connecting spheres wth cones, it's better to use the 
Connect_Spheres() macro from shapes.inc; otherwise the result is not 
completely smooth when there's a big difference between the radii of the two 
spheres.

Rune
-- 
http://runevision.com


Post a reply to this message

From: Rune
Subject: Re: sphere_sweep bug workaround needed
Date: 24 Aug 2007 22:05:16
Message: <46cf8e5c@news.povray.org>
Rune wrote:
> Tim Attwood wrote:
>> I'd use a macro...

Thanks by the way!

The macro you posted was very easy to adapt to my needs. I made a few monor 
adjustments, and now there's not one pixel difference between the new 
sphere+cone sweep and the sphere_sweep before - except those that were the 
error of course. ;)

#include "shapes.inc"

#macro Sphere_Sweep(SPL, from, to, rez)
   #local C = from;
   sphere {<SPL(C).x,SPL(C).y,SPL(C).z>, SPL(C).t}
   #while (C<to-rez)
      Connect_Spheres(
         <SPL(C    ).x,SPL(C    ).y,SPL(C    ).z>, SPL(C    ).t,
         <SPL(C+rez).x,SPL(C+rez).y,SPL(C+rez).z>, SPL(C+rez).t
      )
      sphere {
         <SPL(C+rez).x,SPL(C+rez).y,SPL(C+rez).z>, SPL(C+rez).t
      }
      #local C = C+rez;
   #end
   Connect_Spheres(
      <SPL(C ).x,SPL(C ).y,SPL(C ).z>, SPL(C ).t,
      <SPL(to).x,SPL(to).y,SPL(to).z>, SPL(to).t
   )
   sphere {
      <SPL(to).x,SPL(to).y,SPL(to).z>, SPL(to).t
   }
#end

Rune
-- 
http://runevision.com


Post a reply to this message

From: Tim Attwood
Subject: Re: sphere_sweep bug workaround needed
Date: 25 Aug 2007 04:00:13
Message: <46cfe18d$1@news.povray.org>
Cool, I didn't know about the Connect_Spheres macro.
Learn something every day =)


Post a reply to this message

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