POV-Ray : Newsgroups : povray.binaries.utilities : Bicubic patch to mesh? Server Time
31 Oct 2024 19:30:31 EDT (-0400)
  Bicubic patch to mesh? (Message 1 to 4 of 4)  
From: jarbee
Subject: Bicubic patch to mesh?
Date: 30 Mar 2001 20:35:26
Message: <3ac5345e@news.povray.org>
Does there exist a freeware utility for converting bicubic patch objects to
triangle mesh objects? I have a few patches that I need to carry out CSG on,
the only way I can think of is by converting them to a mesh.

Also, is there any good tutorials on bicubic patches, that explain their
theory in an easy-to-grasp manner?

Dave


Post a reply to this message

From: John VanSickle
Subject: Re: Bicubic patch to mesh?
Date: 13 Apr 2001 17:39:06
Message: <3AD772B7.C88CC3B0@erols.com>
jarbee wrote:
> 
> Does there exist a freeware utility for converting bicubic patch objects to
> triangle mesh objects? I have a few patches that I need to carry out CSG on,
> the only way I can think of is by converting them to a mesh.

This macro takes the control points of a bicubic patch and creates the triangles.
Being recursive, it's slow.  I used this to create the meshes for the Greb
characters in my IRTC entries.  P0 through PF are the control points, and
Div is the number of times to divide.

#macro Bicubic(P0,P1,P2,P3,P4,P5,P6,P7,P8,P9,PA,PB,PC,PD,PE,PF,Div)
  #if (Div<1)
    smooth_triangle {
      P0, vcross(P1-P0,P4-P0),
      P3, vcross(P7-P3,P2-P3),
      PF, vcross(PE-PF,PB-PF) }
    smooth_triangle {
      P0, vcross(P1-P0,P4-P0),
      PF, vcross(PE-PF,PB-PF),
      PC, vcross(P8-PC,PD-PC) }
  #else
  Bicubic(
    P0,
    (P0+P1)/2,
    (P0+2*P1+P2)/4,
    (P0+3*P1+3*P2+P3)/8,

    (P0              + P4)/2,
    (P0+P1           + P4+P5)/4,
    (P0+2*P1+P2      + P4+2*P5+P6)/8,
    (P0+3*P1+3*P2+P3 + P4+3*P5+3*P6+P7)/16,

    (P0              + 2*P4                + P8)/4,
    (P0+P1           + 2*P4+2*P5           + P8+P9)/8,
    (P0+2*P1+P2      + 2*P4+4*P5+2*P6      + P8+2*P9+PA)/16,
    (P0+3*P1+3*P2+P3 + 2*P4+6*P5+6*P6+2*P7 + P8+3*P9+3*PA+PB)/32,

    (P0              + 3*P4                + 3*P8                + PC)/8,
    (P0+P1           + 3*P4+3*P5           + 3*P8+3*P9           + PC+PD)/16,
    (P0+2*P1+P2      + 3*P4+6*P5+3*P6      + 3*P8+6*P9+3*PA      + PC+2*PD+PE)/32,
    (P0+3*P1+3*P2+P3 + 3*P4+9*P5+9*P6+3*P7 + 3*P8+9*P9+9*PA+3*PB + PC+3*PD+3*PE+PF
)/64,
    Div-1)

  Bicubic(
    (P0+3*P1+3*P2+P3)/8,
    (P1+2*P2+P3)/4,
    (P2+P3)/2,
     P3,

    ( P0+3*P1+3*P2+P3 + P4+3*P5+3*P6+P7 )/16,
    ( P1+2*P2+P3 +      P5+2*P6+P7 )/8,
    ( P2+P3 +           P6+P7 )/4,
    ( P3 +              P7 )/2,

    ( P0+3*P1+3*P2+P3 +2*P4+6*P5+6*P6+2*P7 + P8+3*P9+3*PA+PB)/32,
    ( P1+2*P2+P3 +     2*P5+4*P6+2*P7 +      P9+2*PA+PB)/16,
    ( P2+P3 +          2*P6+2*P7 +           PA+PB)/8,
    ( P3 +             2*P7 +                PB)/4,

    ( P0+3*P1+3*P2+P3 + 3*P4+9*P5+9*P6+3*P7 + 3*P8+9*P9+9*PA+3*PB + PC+3*PD+3*PE+PF
)/64,
    ( P1+2*P2+P3 +      3*P5+6*P6+3*P7 +      3*P9+6*PA+3*PB +      PD+2*PE+PF )/32,
    ( P2+P3 +           3*P6+3*P7 +           3*PA+3*PB +           PE+PF )/16,
    ( P3 +              3*P7 +                3*PB +                PF )/8,

    Div-1)

  Bicubic(
    (P0              + 3*P4                + 3*P8                + PC)/8,
    (P0+P1           + 3*P4+3*P5           + 3*P8+3*P9           + PC+PD)/16,
    (P0+2*P1+P2      + 3*P4+6*P5+3*P6      + 3*P8+6*P9+3*PA      + PC+2*PD+PE)/32,
    (P0+3*P1+3*P2+P3 + 3*P4+9*P5+9*P6+3*P7 + 3*P8+9*P9+9*PA+3*PB + PC+3*PD+3*PE+PF
)/64,

    ( P4              + 2*P8                + PC )/4,
    ( P4+P5           + 2*P8+2*P9           + PC+PD )/8,
    ( P4+2*P5+P6      + 2*P8+4*P9+2*PA      + PC+2*PD+PE)/16,
    ( P4+3*P5+3*P6+P7 + 2*P8+6*P9+6*PA+2*PB + PC+3*PD+3*PE+PF )/32,

    ( P8              + PC)/2,
    ( P8+P9           + PC+PD)/4,
    ( P8+2*P9+PA      + PC+2*PD+PE)/8,
    ( P8+3*P9+3*PA+PB + PC+3*PD+3*PE+PF )/16,

    PC,
    ( PC+PD)/2,
    ( PC+2*PD+PE)/4,
    ( PC+3*PD+3*PE+PF )/8,
    Div-1)

  Bicubic(
    ( P0+3*P1+3*P2+P3 + 3*P4+9*P5+9*P6+3*P7 + 3*P8+9*P9+9*PA+3*PB + PC+3*PD+3*PE+PF
)/64,
    ( P1+2*P2+P3 +      3*P5+6*P6+3*P7 +      3*P9+6*PA+3*PB +      PD+2*PE+PF )/32,
    ( P2+P3 +           3*P6+3*P7 +           3*PA+3*PB +           PE+PF )/16,
    ( P3 +              3*P7 +                3*PB +                PF )/8,

    ( P4+3*P5+3*P6+P7 + 2*P8+6*P9+6*PA+2*PB + PC+3*PD+3*PE+PF )/32,
    ( P5+2*P6+P7      + 2*P9+4*PA+2*PB      + PD+2*PE+PF )/16,
    ( P6+P7           + 2*PA+2*PB           + PE+PF )/8,
    ( P7              + 2*PB                + PF )/4,

    ( P8+3*P9+3*PA+PB + PC+3*PD+3*PE+PF )/16,
    ( P9+2*PA+PB      + PD+2*PE+PF )/8,
    ( PA+PB           + PE+PF )/4,
    ( PB              + PF )/2,

    ( PC+3*PD+3*PE+PF )/8,
    ( PD+2*PE+PF )/4,
    ( PE+PF )/2,
    ( PF )/1,
    Div-1)

  #end
#end

Hope this helps,
John

-- 
ICQ: 46085459


Post a reply to this message

From: jarbee
Subject: Re: Bicubic patch to mesh?
Date: 16 Apr 2001 19:31:49
Message: <3adb80e5@news.povray.org>
"John VanSickle" <van### [at] erolscom> wrote in message
news:3AD772B7.C88CC3B0@erols.com...
>
> This macro takes the control points of a bicubic patch and creates the
triangles.
> Being recursive, it's slow.  I used this to create the meshes for the Greb
> characters in my IRTC entries.  P0 through PF are the control points, and
> Div is the number of times to divide.
>
> #macro Bicubic(P0,P1,P2,P3,P4,P5,P6,P7,P8,P9,PA,PB,PC,PD,PE,PF,Div)
>   #if (Div<1)
>     smooth_triangle {
>       P0, vcross(P1-P0,P4-P0),
>       P3, vcross(P7-P3,P2-P3),
>       PF, vcross(PE-PF,PB-PF) }
>     smooth_triangle {
>       P0, vcross(P1-P0,P4-P0),
>       PF, vcross(PE-PF,PB-PF),
>       PC, vcross(P8-PC,PD-PC) }
>   #else
>   Bicubic(
>     P0,
>     (P0+P1)/2,
>     (P0+2*P1+P2)/4,
>     (P0+3*P1+3*P2+P3)/8,
>
>     (P0              + P4)/2,
>     (P0+P1           + P4+P5)/4,
>     (P0+2*P1+P2      + P4+2*P5+P6)/8,
>     (P0+3*P1+3*P2+P3 + P4+3*P5+3*P6+P7)/16,
>
>     (P0              + 2*P4                + P8)/4,
>     (P0+P1           + 2*P4+2*P5           + P8+P9)/8,
>     (P0+2*P1+P2      + 2*P4+4*P5+2*P6      + P8+2*P9+PA)/16,
>     (P0+3*P1+3*P2+P3 + 2*P4+6*P5+6*P6+2*P7 + P8+3*P9+3*PA+PB)/32,
>
>     (P0              + 3*P4                + 3*P8                + PC)/8,
>     (P0+P1           + 3*P4+3*P5           + 3*P8+3*P9           +
PC+PD)/16,
>     (P0+2*P1+P2      + 3*P4+6*P5+3*P6      + 3*P8+6*P9+3*PA      +
PC+2*PD+PE)/32,
>     (P0+3*P1+3*P2+P3 + 3*P4+9*P5+9*P6+3*P7 + 3*P8+9*P9+9*PA+3*PB +
PC+3*PD+3*PE+PF )/64,
>     Div-1)
>
>   Bicubic(
>     (P0+3*P1+3*P2+P3)/8,
>     (P1+2*P2+P3)/4,
>     (P2+P3)/2,
>      P3,
>
>     ( P0+3*P1+3*P2+P3 + P4+3*P5+3*P6+P7 )/16,
>     ( P1+2*P2+P3 +      P5+2*P6+P7 )/8,
>     ( P2+P3 +           P6+P7 )/4,
>     ( P3 +              P7 )/2,
>
>     ( P0+3*P1+3*P2+P3 +2*P4+6*P5+6*P6+2*P7 + P8+3*P9+3*PA+PB)/32,
>     ( P1+2*P2+P3 +     2*P5+4*P6+2*P7 +      P9+2*PA+PB)/16,
>     ( P2+P3 +          2*P6+2*P7 +           PA+PB)/8,
>     ( P3 +             2*P7 +                PB)/4,
>
>     ( P0+3*P1+3*P2+P3 + 3*P4+9*P5+9*P6+3*P7 + 3*P8+9*P9+9*PA+3*PB +
PC+3*PD+3*PE+PF )/64,
>     ( P1+2*P2+P3 +      3*P5+6*P6+3*P7 +      3*P9+6*PA+3*PB +
PD+2*PE+PF )/32,
>     ( P2+P3 +           3*P6+3*P7 +           3*PA+3*PB +
          PE+PF )/16,
>     ( P3 +              3*P7 +                3*PB +
               PF )/8,
>
>     Div-1)
>
>   Bicubic(
>     (P0              + 3*P4                + 3*P8                + PC)/8,
>     (P0+P1           + 3*P4+3*P5           + 3*P8+3*P9           +
PC+PD)/16,
>     (P0+2*P1+P2      + 3*P4+6*P5+3*P6      + 3*P8+6*P9+3*PA      +
PC+2*PD+PE)/32,
>     (P0+3*P1+3*P2+P3 + 3*P4+9*P5+9*P6+3*P7 + 3*P8+9*P9+9*PA+3*PB +
PC+3*PD+3*PE+PF )/64,
>
>     ( P4              + 2*P8                + PC )/4,
>     ( P4+P5           + 2*P8+2*P9           + PC+PD )/8,
>     ( P4+2*P5+P6      + 2*P8+4*P9+2*PA      + PC+2*PD+PE)/16,
>     ( P4+3*P5+3*P6+P7 + 2*P8+6*P9+6*PA+2*PB + PC+3*PD+3*PE+PF )/32,
>
>     ( P8              + PC)/2,
>     ( P8+P9           + PC+PD)/4,
>     ( P8+2*P9+PA      + PC+2*PD+PE)/8,
>     ( P8+3*P9+3*PA+PB + PC+3*PD+3*PE+PF )/16,
>
>     PC,
>     ( PC+PD)/2,
>     ( PC+2*PD+PE)/4,
>     ( PC+3*PD+3*PE+PF )/8,
>     Div-1)
>
>   Bicubic(
>     ( P0+3*P1+3*P2+P3 + 3*P4+9*P5+9*P6+3*P7 + 3*P8+9*P9+9*PA+3*PB +
PC+3*PD+3*PE+PF )/64,
>     ( P1+2*P2+P3 +      3*P5+6*P6+3*P7 +      3*P9+6*PA+3*PB +
PD+2*PE+PF )/32,
>     ( P2+P3 +           3*P6+3*P7 +           3*PA+3*PB +
          PE+PF )/16,
>     ( P3 +              3*P7 +                3*PB +
               PF )/8,
>
>     ( P4+3*P5+3*P6+P7 + 2*P8+6*P9+6*PA+2*PB + PC+3*PD+3*PE+PF )/32,
>     ( P5+2*P6+P7      + 2*P9+4*PA+2*PB      + PD+2*PE+PF )/16,
>     ( P6+P7           + 2*PA+2*PB           + PE+PF )/8,
>     ( P7              + 2*PB                + PF )/4,
>
>     ( P8+3*P9+3*PA+PB + PC+3*PD+3*PE+PF )/16,
>     ( P9+2*PA+PB      + PD+2*PE+PF )/8,
>     ( PA+PB           + PE+PF )/4,
>     ( PB              + PF )/2,
>
>     ( PC+3*PD+3*PE+PF )/8,
>     ( PD+2*PE+PF )/4,
>     ( PE+PF )/2,
>     ( PF )/1,
>     Div-1)
>
>   #end
> #end
>

I think that's what I needed, thanx. I've only tried it quickly so far, but
it seems to do a good job. I was thinking of incorporating it into a program
to do the conversions. Is that ok?

Dave


Post a reply to this message

From: John VanSickle
Subject: Re: Bicubic patch to mesh?
Date: 18 Apr 2001 14:09:07
Message: <3ADDD903.32309DF7@erols.com>
jarbee wrote:
> 
> John VanSickle wrote:
>
> > This macro takes the control points of a bicubic patch and creates
> > the triangles.
> > Being recursive, it's slow.  I used this to create the meshes for
> > the Greb characters in my IRTC entries.  P0 through PF are the
> > control points, and Div is the number of times to divide.

<macro snipped>

> I think that's what I needed, thanx. I've only tried it quickly so
> far, but it seems to do a good job. I was thinking of incorporating it
> into a program to do the conversions. Is that ok?

Yeah, sure.

Regards,
John
-- 
ICQ: 46085459


Post a reply to this message

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