POV-Ray : Newsgroups : povray.general : Another bicubic patch question : Re: Another bicubic patch question Server Time
8 Aug 2024 14:24:31 EDT (-0400)
  Re: Another bicubic patch question  
From: Chris Colefax
Date: 11 Dec 2000 03:58:21
Message: <3a34972d@news.povray.org>
Rune <run### [at] inamecom> wrote:
> How do I make patches fit seamlessly together when the number of patches
> that has corners in the same point is not 4?
>
> The usual trick of having the points aligned in lines doesn't seem to
apply,
> since it only makes sense when there's 4 patches sharing a corner.
>
> So as an example, how would the code for a sphere made of 6 patches (think
> dice) look? And which guidelines should be used to achieve it?

The code below creates something like a sphere based on a cube of patches.
You can toggle the hull to see the tangent lines, edges and corners.
However, I would cautiously say that getting anything as good as the last
(8-patch) sphere is impossible with this arrangement - tweak the V1 and V2
parameters as I might, I can't seem to get a shape that is close to
spherical *and* smooth at the seams (if you comment out the reference sphere
and turn off the hull you can clearly see the discontinuities in shading).
Of course, Rune, you might have a little more luck...!

camera {location <1, 3, -4> look_at <0, 0, 0>}
light_source {<-200, 300, -400> rgb 1.3}
background {rgb 0.5}

// Reference sphere
sphere {0, sqrt(3) pigment {rgbt <1, 0, 0, .5>}}

// Tweaking parameters
#declare ShowHull = yes;
#declare ShowPatches = yes;

#declare V1 = .76; // Edge tangents
#declare V2 = 1.8; // Centre tangents
#declare R = .02; // Hull radius

// Corner points (equates to sphere with radius sqrt(3))
#declare C1 = <1, 1, -1>; #declare C2 = <-1, 1, -1>;
#declare C3 = <-1, 1, 1>; #declare C4 = <1, 1, 1>;

// Edge tangents
#declare T14 = V1*vrotate(vrotate(y, -z*60),
<degrees(acos(sqrt(2)/sqrt(3))), -45, 0>);
#declare T12 = V1*vrotate(vrotate(y, z*60),
<degrees(acos(sqrt(2)/sqrt(3))), -45, 0>);
#declare T21 = vrotate(T14, y*90);  #declare T23 = vrotate(T12, y*90);
#declare T32 = vrotate(T14, y*180); #declare T34 = vrotate(T12, y*180);
#declare T43 = vrotate(T14, y*270); #declare T41 = vrotate(T12, y*270);

// Centre tangent
#declare TM = V1*vrotate(y, <degrees(acos(sqrt(2)/sqrt(3))), -45, 0>);

// Centre points
#declare M1 = C1 + TM*V2;
#declare M2 = vrotate(M1, y*90);
#declare M3 = vrotate(M1, y*180);
#declare M4 = vrotate(M1, y*270);

#declare P = union {
#if (ShowPatches)
   bicubic_patch {
      type 1 u_steps 3 v_steps 3 flatness .01
      C1, C1+T12, C2+T21, C2,
      C1+T14, M1, M2, C2+T23,
      C4+T41, M4, M3, C3+T32,
      C4, C4+T43, C3+T34, C3}
#end

#if (ShowHull)
   union {
      cylinder {C1, C1+T12, R}
      cylinder {C1+T12, C2+T21, R}
      cylinder {C2+T21, C2, R}

      cylinder {C1+T14, M1, R}
      cylinder {M1, M2, R}
      cylinder {M2, C2+T23, R}

      cylinder {C4+T41, M4, R}
      cylinder {M4, M3, R}
      cylinder {M3, C3+T32, R}

      cylinder {C4, C4+T43, R}
      cylinder {C4+T43, C3+T34, R}
      cylinder {C3+T34, C3, R}

      cylinder {C1, C1+T14, R}
      cylinder {C1+T14, C4+T41, R}
      cylinder {C4+T41, C4, R}

      cylinder {C1+T12, M1, R}
      cylinder {M1, M4, R}
      cylinder {M4, C4+T43, R}

      cylinder {C2+T21, M2, R}
      cylinder {M2, M3, R}
      cylinder {M3, C3+T34, R}

      cylinder {C2, C2+T23, R}
      cylinder {C2+T23, C3+T32, R}
      cylinder {C3+T32, C3, R}

      pigment {rgb <0, 1, 0>}
      no_shadow
      }
   #end
}

union {
   object {P}
   object {P rotate x*90}
   object {P rotate x*180}
   object {P rotate x*270}
   object {P rotate z*-90}
   object {P rotate z*90}
   pigment {rgb 1}
   }


Post a reply to this message

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