POV-Ray : Newsgroups : povray.advanced-users : Fitting together bicubic patches Server Time
1 Nov 2024 05:20:53 EDT (-0400)
  Fitting together bicubic patches (Message 1 to 6 of 6)  
From: sascha
Subject: Fitting together bicubic patches
Date: 17 Jul 2003 13:22:41
Message: <3f16db61$1@news.povray.org>
I'd like to fit togehter two coon's-patches (a coon's patch is a bicubic 
patch with the inner 4 control points missing):
Take a look at my "ascii-art" :-) below (use a fixed width font like 
courier)

Control-Point numbering for bezier patches:

0--1--2--3
|  |  |  |
4--5--6--7
|  |  |  |
8--9--10-11
|  |  |  |
12-13-14-15

Two coon's patches...

0--1--2--3     0--1--2--3
|        |     |        |
4        7     4        7
|   A    |     |   B    |
8        11    8        11
|        |     |        |
12-13-14-15    12-13-14-15

...fitted together...

*--*--*--*--*--*--*
|        |        |
*        *        *
|        |        |
*        *        *
|        |        |
*--*--*--*--*--*--*

Fitting together patch A and B is easy, the joining-points have to match 
(A3 = B0, A7 = B4, A11 = B8 and A15 ? B12) and
the tangents must be colinear (meaning the vector A2-A3 must have the 
same direction as the vector B0-B1 and the vector
A14-A15 must have the same direction as vector B12-B13).

But to render the patches I first have to calculate the missing inner 
controlpoints for the bezier-patch (points 5,6,9 and 10).

One solution is to form parallelograms, e.g. to get point 5 form a 
parallelogram using points 0, 1 and 4:
p5 = p4 + p1 - p0
like:
0-----1
  \     \
   4-----5
but this leads to difficulties in u/v mapping and if I like to subdivide 
a patch...

Has anybody got a better solution than forming parallelograms ?


Post a reply to this message

From: sascha
Subject: Re: Fitting together bicubic patches
Date: 17 Jul 2003 15:51:31
Message: <3f16fe43$1@news.povray.org>
Allright, I've got a solution.

What really amazes me is that I thought about this for several days now, 
and shortly after "giving up" and posting it here I found a solution...


Post a reply to this message

From: David Wallace
Subject: Re: Fitting together bicubic patches
Date: 18 Jul 2003 00:23:34
Message: <3f177646$1@news.povray.org>
"sascha" <sas### [at] userssourceforgenet> wrote in message
news:3f16fe43$1@news.povray.org...
> Allright, I've got a solution.
>
> What really amazes me is that I thought about this for several days now,
> and shortly after "giving up" and posting it here I found a solution...
>
Well, let's see the solution!  Others might benefit from what you found.


Post a reply to this message

From: sascha
Subject: Re: Fitting together bicubic patches
Date: 18 Jul 2003 02:01:07
Message: <3f178d23@news.povray.org>
Ok, it's a bit difficult to explain in english for me, but let's
see...

0--1--2--3
|  |  |  |
4--5--6--7
|  |  |  |
8--9--10-11
|  |  |  |
12-13-14-15

To connect two bicubic patches, they must share four common control
points.

0--1--2--3 = 0--1--2--3
|        |   |        |
4        7 = 4        7
|   A    |   |   B    |
8        11= 8        11
|        |   |        |
12-13-14-15= 12-13-14-15

To maintain G1 geometric continuity, the tangent vectors at the
joins muts have the same direction, meaning:
vector A2A3 must have same direction as B0B1
vector A6A7 must have same direction as B4B5
vector A10A11 must have same direction as B8B9
vector A14A15 must have same direction as B12B13

If it's to connect four or more patches the same rules are true. Ok,
in my case the splines that make up the outlines of the patches are
already set up (and are per definition g1 contingous), so the
problem is computing the inner control-points 5,6,9 and 10 for the
bezier patch.

In this example four patches (1,2,3,4) should be joined together:

*---*---*---*---*---*---*
|   |   |   |   |   |   |
*---*---*---*---*---*---*
|   | 1 |   |   | 2 |   |
*---*---A---B---C---*---*
|   |   |   |   |   |   |
*===*===D===E===F===*===*
|   |   |   |   |   |   |
*---*---G---H---I---*---*
|   | 3 |   |   | 4 |   |
*---*---*---*---*---*---*
|   |   |   |   |   |   |
*---*---*---*---*---*---*

They share common control-points B,D,E,F and H (which are given, and
vector BE is colinear with EH, vector DE is colinear with EF). There
are two constrains for point A,C,G and I if G1 continuity is to be
maintained:
1) E,A,C,G,I must be on the same plane
2) vectoer DA must be colinear to GD, FC to IF, AB to BC and GH to
HI

An easy way for doing this is to compute parallelograms, that is
A = B + D - E,
C = B + F - E,
G = H + D - E,
I = H + F - E

but this is not the best sulution, if the patches look somehow like
this:

                0-1-2-3
               / /     \
              4-5       7
             /     A     \
            8-----9       10
           /     /         \
          11----12----13----14
         /     /             \
        4-----5               7
       /           B           \
      8---------9               11
     /         /                 \
    12--------13--------14--------15

You can see that the constrains are met, but in this case it would
look better if the newly computed points would be on a streight line:
A1-A5-A9-A12=B1-B5-B9-B12. You can imagine that this makes problems
in u/v mapping and when trying to subdivide one patch (by replacing
it with two or four other patches).

Ok, so the solution I probably found (I tried it and it looks good)
is:

0--1--2--3
|  |  |  |
4--5--6--7
|  |  |  |
8--9--10-11
|  |  |  |
12-13-14-15

I want to compute the position of control-point 5

1.) Set up a plane 0-1-4

2.) vector v0_4 is the vector from 0 to 4 (4 - 0)
     vector v3_7 is the vector from 3 to 7 (7 - 3)
     vector v0_1 is the vector from 0 to 1 (1 - 0)
     vector v12_13 is the vector from 12 to 13 (13 - 12)

Now "blend" those vectors to find v1_5 and v4_5:

3.) vector v1_5 = 2/3 * v0_4 + 1/3 * v3_7
     vector v4_5 = 2/3 * v0_1 + 1/3 * v12_13

4.) line L1_5 goes through point 1 and has vector v1_5
     line L4_5 goes through point 4 and has vector v4_5

In 3D space these lines might have no intersection, so:

5.) Project lines L1_5 and L4_5 to the plane 0-1-4

These projected lines of course have an intersection (they're on
the same plane)

6.) Compute intersection of projected lines - and voila, this
intersection is point 5

That's it - I have to do further tests with this method, but until
now the results look good (much better than with the parallelogram
method). If you wonder why I need this, it's for my modeller-project
"JPatch" - which is an sPatch like modeler. As far as I know (by
looking at sPatch output files) sPatch uses the parallelogram method.
I need a better method for 3- and 5- sided patches and
Animation:Master style "hooks". sPatch uses 1 degenerate bezier-patch
for 3-sided patches and hase no support for 5-sided patches and
hooks.
If this method proofs to be good you'll find an implementation in the
upcoming version 0.3 of JPatch (it's open-source) and I'll probably
explain it in more details (or at least with some better pictures
and diagrams) in the developer-section of the JPatch homepage
http://jpatch.sourceforge.net

-sascha


Post a reply to this message

From: ABX
Subject: Re: Fitting together bicubic patches
Date: 18 Jul 2003 02:07:32
Message: <fh3fhvcaq529lnnsfmtikn9lr6od1htksr@4ax.com>
On Fri, 18 Jul 2003 08:00:47 +0200, sascha <sas### [at] userssourceforgenet>
wrote:
> 1.) Set up a plane 0-1-4

What if 0-1-4 make single line ?

ABX


Post a reply to this message

From: sascha
Subject: Re: Fitting together bicubic patches
Date: 18 Jul 2003 02:43:08
Message: <3f1796fc@news.povray.org>
That's a good question - fallback to the parallelogram-method might be a 
solution...

But I'm not sure if this is valid anyway, as the renderer will try to 
compute a surface normal on point 0 it would fail, wouldn't it? I have 
to look...

-sascha

ABX wrote:
> On Fri, 18 Jul 2003 08:00:47 +0200, sascha <sas### [at] userssourceforgenet>
> wrote:
> 
>>1.) Set up a plane 0-1-4
> 
> 
> What if 0-1-4 make single line ?
> 
> ABX


Post a reply to this message

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