POV-Ray : Newsgroups : povray.general : uv mapping for isosurfaces - when? : Re: uv mapping for isosurfaces - when? Server Time
2 Aug 2024 00:11:45 EDT (-0400)
  Re: uv mapping for isosurfaces - when?  
From: Mike Williams
Date: 22 Feb 2005 01:40:56
Message: <MK3AtAA6NtGCFwy$@econym.demon.co.uk>
Wasn't it Christopher James Huff who wrote:
>In article <4219fc6a@news.povray.org>,
> "William Peska" <wil### [at] yahoocom> wrote:
>
>It'd help if you gave a little more detail...for instance, maybe 
>describing what you think such a feature would do. As it is, you're 
>essentially asking for "magic".
>
>There's nothing particularly special about UV coordinates, you pick a 
>system that fits your purpose. For instance, for UV-mapping a sphere, 
>you usually pick spherical coordinates...that would not work well for a 
>torus. It could work for a box, but you'd probably pick a mapping 
>designed specifically for boxes instead. The shape of an isosurface is 
>very arbitrary, it could be a sphere, a torus, or something far more 
>complex. There is simply no way for POV to guess what you might want.
>
>One possibility that does come to mind would be to allow the user to 
>specify a pair of functions mapping XYZ coordinates to UV coordinates. 
>It would not be particularly easy to use, though. It is in fact already 
>possible, though you have to jump through a few hoops...you need to use 
>a function pattern that implements the desired mapping. For example 
>(untested!):
>
>#declare basePattern = function {pattern {checker scale 0.1}};
>
>#declare uFn = function (x, y, z) {
>    atan(x, z)/(2*pi) + 0.5
>};
>
>#declare vFn = function (x, y, z) {
>    atan(y, sqrt(x*x + z*z))/(2*pi) + 0.5
>};
>
>isosurface {
>    ...
>    pigment {function {basePattern(uFn(x, y, z), vFn(x, y, z), 0)}
>        ...
>    }
>}

I was wondering if something like that could be achieved.

For a sensible result you'd really want to find a set of functions that
had the property that uFn, vFn and the surface function be orthogonal
everywhere. That would be the 3d equivalent to what are called
"orthogonal trajectories" of a family of curves in 2d. In the 2d case,
there's a method for finding orthogonal trajectories if you can find a
differential equation that describes the family of curves and then solve
the inverse of that differential equation. Consider the family of
surfaces produced by using different values of "threshold", then find
two other families of surfaces that are the 3d orthogonal trajectories.

The 3d case is likely to be a bit more awkward to calculate, if for no
other reason than the fact that there isn't a unique solution like there
is in the 2d case.

In a really simple case, I happen to know that f_sphere(), f_th() and
f_ph() are orthogonal everywhere, so that gives us something we can
check. Here's a complete scene using the technique (in this case the
scale needs to be a fraction of pi to prevent a discontinuity). 

camera { location  <0, 0, -2.5> look_at <0, 0, 0>}
light_source {<-100,200,-100> colour rgb 1}

#include "functions.inc"
#declare basePattern = function {pattern {checker scale pi/20}};
#declare uFn = function{f_th(x,y,z)}
#declare vFn = function{f_ph(x,y,z)}
#declare Surface = function {f_sphere(x,y,z,1)}

isosurface {
  function { Surface(x,y,z) }
        max_gradient 2.2
        contained_by{sphere{0,1.1}}
        pigment {function {basePattern(uFn(x, y, z), vFn(x, y, z), 0)}}
}

All we need to do now is derive such orthogonal functions in the general
case.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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