     POV-Ray : Newsgroups : povray.general : Curved Triangles : Re: Curved Triangles Server Time17 Oct 2021 21:19:33 EDT (-0400) Re: Curved Triangles   From: John VanSickle Date: 29 Jun 2002 10:57:20 Message: <3D1DCAD0.90317117@hotmail.com>    ```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"dateCreated": "2002-06-29T14:57:20+00:00",
"datePublished": "2002-06-29T14:57:20+00:00",
"author": {
"@type": "Person",
"name": "John VanSickle"
}
}
Ben Chambers wrote:
>
> "John VanSickle" <evi### [at] hotmail com> wrote in message
> news:3D1B59E3.54F30927@hotmail.com...
> > > BTW, it's late here, and I haven't had time to try any meshes
> > > with it. Please let me know if you run into problems doing so
> > > (smooth triangles should convert without problems, but you never
> > > know).
> >
> > I have some code (untested--Rusty takes priority!) that implements
> > a quartic triangular Bezier patch.  There is supposedly an algorithm
> > by which a Loop subdivision surface can be converted into a bunch of
> > these (which makes them much easier to implement).
>
> All the effort I put into it, and the code already exists somewhere
> else?!?!?  Aaaaargh!
>
> That's what I get for not researching the topic first!

Yup.  Google is wonderful, but only if you use it.

> BTW, where is that code you were talking about?

Here is the UNTESTED code:

// start of macro code
#macro TriBezier(pA,pB,pC,pD,pE,pF,pG,pH,pI,pJ,pK,pL,pM,pN,pO,cD)
#if(cD<1)
smooth_triangle {
A,vcross(C-A,B-A),
K,vcross(G-K,L-K),
O,vcross(N-O,J-O)
}
#else
TriBezier(A,(A+B)/2,(A+C)/2,(A+2*B+D)/4,(A+B+C+E)/4,(A+2*C+F)/4,
(A+3*B+3*D+G)/8,(A+2*B+D+C+2*E+H)/8,(A+2*C+F+B+2*E+I)/8,
(A+3*C+3*F+J)/8,(A+4*B+6*D+4*G+K)/16,(A+3*B+3*D+G+C+3*E+3*H+L)/16,
(A+2*C+F+2*B+4*E+2*I+D+2*H+M)/16,(A+3*C+3*F+J+B+3*E+3*I+N)/16,
(A+4*C+6*F+4*J+O)/16,cD-1)

TriBezier((A+4*B+6*D+4*G+K)/16,(B+3*D+3*G+K)/8,(B+C+3*D+3*E+3*G+3*H+K+L)/16,
(D+2*G+K)/4,(D+E+2*G+2*H+K+L)/8,(D+2*E+F+2*G+4*H+2*I+K+2*L+M)/16,
(G+K)/2,(G+H+K+L)/4,(G+2*H+I+K+2*L+M)/8,(G+3*H+3*I+J+K+3*L+3*M+N)/16,
K,(K+L)/2,(K+2*L+M)/4,(K+3*L+3*M+N)/8,(K+4*L+6*M+4*N+O)/16,cD-1)

TriBezier((A+4*C+6*F+4*J+O)/16,(B+C+3*E+3*F+3*I+3*J+N+O)/16,
(C+3*F+3*J+O)/8,(D+2*E+F+2*H+4*I+2*J+M+2*N+O)/16,(E+F+2*I+2*J+N+O)/8,
(F+2*J+O)/4,(G+3*H+3*I+J+L+3*M+3*N+O)/16,(H+2*I+J+M+2*N+O)/8,
(I+J+N+O)/4,(J+O)/2(K+4*L+6*M+4*N+O)/16,(L+3*M+3*N+O)/8,(M+2*N+O)/4,
(N+O)/2,O,cD-1)

TriBezier((A+4*B+6*D+4*G+K)/16,(A+3*B+3*D+G+C+3*E+3*H+L)/16,
(A+2*B+D+2*C+4*E+2*H+F+2*I+M)/16(A+3*C+3*F+J+B+3*E+3*I+N)/16,
(A+4*C+6*F+4*J+O)/16,(B+C+3*D+3*E+3*G+3*H+K+L)/16,
(B+C+2*D+3*E+F+G+3*H+2*I+L+M)/16,(B+C+D+3*E+2*F+2*H+3*I+J+M+N)/16,
(B+C+3*E+3*F+3*I+3*J+N+O)/16,(D+2*E+F+2*G+4*H+2*I+K+2*L+M)/16,
(D+2*E+F+G+3*H+3*I+J+L+2*M+N)/16,(D+2*E+F+2*H+4*I+2*J+M+2*N+O)/16,
(G+3*H+3*I+J+K+3*L+3*M+N)/16,(G+3*H+3*I+J+L+3*M+3*N+O)/16,
(K+4*L+6*M+4*N+O)/16,cD-1)
#end
#end

// end of macro code

I am also generalizing my surface subdivision code to include four-
sided faces (which helps solve a couple of problems with uv-mapping).
That project isn't done yet.

Regards,
John
```    