POV-Ray : Newsgroups : povray.binaries.images : Bezier-patch torus : Re: Bezier-patch torus Server Time
21 May 2024 15:49:49 EDT (-0400)
  Re: Bezier-patch torus  
From: clipka
Date: 5 Sep 2018 21:27:16
Message: <5b908274$1@news.povray.org>
So, you don't understand how UV mapping of Bezier patches works, and
want some clearer explanation?

Here's the deal:

In a sense, you can interpret Bezier patches as parametrics - except
that their functions are not specified explicitly, but rather are
bicubic polynomials (i.e. the sum of a[i,j]*u^i*v^j with i+j<=3, and
i,j>=0) defined implicitly via the control points.

The U coordinate runs along one edge, while the V coordinate runs along
the other edge.

Just like with parametrics, the U and V coordinates each run from 0 to 1
by default.


This default behaviour can be changed though, by specifying:

    uv_vectors UV00, UV10, UV11, UV01

where UV00 through UV11 are 2D vectors: Each specify the values U and V
for one of the corner points of the patch. (Note that the corners are
specified in circular order rather than as a matrix.)

Typically, you would use the form

    uv_vectors <Umin,Vmin>, <Umax,Vmin>, <Umax,Vmax>, <Umin,Vmax>

where Umin,Umax is the range for the U coordinate and Vmin,Vmax is the
range for the V coordinate.

If this special form is /not/ followed, things get a bit more
complicated; probably the easiest way to envision this is to consider
the function parameters and the UV mapping coordinates as separate
things (which is how it's actually implemented anyway); so for that sake
let's call the function parameters phi and theta; then the UV coordinate
for any given (phi;theta) parameter pair is computed as:

    UV = UV00 * (1-phi) * (1-theta)
       + UV10 *   phi   * (1-theta)
       + UV01 * (1-phi) *   theta
       + UV11 *   phi   *   theta


This latter interpolation scheme is not explicitly mentioned in the
docs, so I had to dig in the source code for that.

Another important aspect the docs really /fail/ to mention is which
corners UV00, UV10, UV11 and UV01, respectively, correspond to. I
_think_ the correspondence is as follows:

    UV01 aka "corner1" <-> Point_1
    UV10 aka "corner2" <-> Point_4
    UV11 aka "corner3" <-> Point_16
    UV01 aka "corner4" <-> Point_13

but I might be mistaken; for instance, Point_4 and Point_16 could be
swapped. I would have to do more code diving for that, and I deem it
easier for the reader to just try it out than it would be for me to sift
through the source code. (Someone would have to do a reality-check on my
code digging results anyway.)


Post a reply to this message

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