POV-Ray : Newsgroups : povray.advanced-users : Nonlinear distortion of <x,y,z> possible? : Re: Nonlinear distortion of <x,y,z> possible? Server Time
3 Jul 2024 05:48:15 EDT (-0400)
  Re: Nonlinear distortion of <x,y,z> possible?  
From: Alain
Date: 6 Jul 2008 12:35:15
Message: <4870f443$1@news.povray.org>
slehar nous illumina en ce 2008-07-06 08:55 -->
> Hi POV-Rayers,
> 
> I'm making a figure for my book that demonstrates the distorting effects of a
> *vergence* measure of distance, i.e. expressing distance as the vergence angle
> between two eyes in a binocular system (things very far away all get "squashed"
> to vergence zero, at infinity, which is why the sun, moon, and distant mountains
> all appear at the same depth perceptually)
> 
> (see http://cns-alumni.bu.edu/~slehar/cartoonepist/cartoonepist1.html )
> 
> I define my vergence measure, or actually its inverse function
> 
> // Inverse vergence function: Does the inverse of the vergence function.
> // This is used to compute the distance x for a given vergence, that is
> // used to define the sinusoidal pigment of the cylinder.
> #declare invergence = function(x) {
>   1.0/(2.0*tan((-x + pi)/2))
> };
> 
> Then I define a color function as a sinusoidal pattern of red and green, that is
> squashed by the inverse vergence function
> 
> // sinusoidal color pattern for the cylinder
> #declare ColorFunc = function (x) {
>        0.5 * (sin(invergence(x)*2*pi*freq)) + 0.5
> }
> 
> Finally, I define a cylinder whose surface is painted with a pigment of that
> function:
> 
> // cylinder painted with squashed sinusoidal pattern
> cylinder {
>   <-3.14159, 0, 0> <3.14159, 0, 0> 0.5      // coords of opposite cap points
>   pigment {
>     function {  ColorFunc (x) }
>     color_map {           // color map
>       [0 color red 1]     // density 0 maps to red
>       [1 color green 1]   // density 1 maps to green
>     }
>   }
>   rotate y*20
> }
> 
> The full source code and the picture it makes can be downloaded here:
> 
> http://cns-alumni.bu.edu/~slehar/POV-Ray/ResonanceVergence.pov
> http://cns-alumni.bu.edu/~slehar/POV-Ray/ResonanceVergence.bmp
> 
> *** MY QUESTION ***
> 
> Is it possible to apply a nonlinear distortion, like my vergence measure, to the
> <x,y,z> space itself so as to distort all objects in the scene? What I'd really
> like to do is apply my vergence distortion to some of the pre-defined patterns
> already available in POV-Ray, such as checker, wood, brick, hexagon, and apply
> the same vergence distortion to them.
> 
> // cylinder painted with checker pattern
> cylinder {
>   <-3.14159, 0, 0> <3.14159, 0, 0> 0.5      // coords of opposite cap points
> pigment {
>      checker
> 
>   }
> }
> 
> You can't do it with the matrix transformation, because you can't put
> <x,y, or z> as elements in the matrix itself...
> 
> ERROR >>>
>   matrix < x*(pi - 2 * atan(1/(2*pi))), 0, 0,
>            0, y*(pi - 2 * atan(1/(2*pi))), 0,
>            0, 0, z*(pi - 2 * atan(1/(2*pi))),
>            0, 0, 0>
>   rotate y*20
> <<< ERROR Float expected but vector or color expression found
> 
> How do I apply my vergence distortion to the <x,y,z> space that the pre-defined
> patterns like checker work on? Is this even possible?
> 
> Many thanks in advance for your kind help,
> 
>   Steve Lehar
> 
> 
> 
> 
> 
> 
> 
To apply any non-linear distortion to an object, you need to convert it into an 
iso_surface and apply your distortion to the function. Objiously, the scene will 
take much longer to render.
If you have a mesh, you can apply your distortion to every point. This will 
actualy change the shape of the mesh. Takes some time to parse, but quick to render.
You can convert the pigment into a function to, then you can apply the 
distortion to that function.

-- 
Alain
-------------------------------------------------
Methodist: It's not so bad if shit happens, as long as you serve grape juice 
with it.


Post a reply to this message

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