POV-Ray : Newsgroups : povray.advanced-users : Nonlinear distortion of <x,y,z> possible? Server Time
1 Nov 2024 03:14:53 EDT (-0400)
  Nonlinear distortion of <x,y,z> possible? (Message 1 to 5 of 5)  
From: slehar
Subject: Nonlinear distortion of <x,y,z> possible?
Date: 6 Jul 2008 09:00:00
Message: <web.4870bb79e5e38f60f75a90cb0@news.povray.org>
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


Post a reply to this message

From: Alain
Subject: Re: Nonlinear distortion of <x,y,z> possible?
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

From: slehar
Subject: Re: Nonlinear distortion of <x,y,z> possible?
Date: 7 Jul 2008 15:30:00
Message: <web.48726e7c9a281388f75a90cb0@news.povray.org>
<<1>>
> 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.
>
<<2>>
> If you have a mesh, you can apply your distortion to every point. This will
> actualy change the shape of the mesh.
>
<<3>>
> You can convert the pigment into a function to, then you can apply the
> distortion to that function.

Thanks for your response.

Option <<3>> is the one I was doing before, thanks for the other two.

But neither of the three will allow me to use pre-defined patterns such as
checker, wood, brick, hexagon, and apply a distortion to them, will they? So I
would have to re-write the code for those patterns in order to apply the
distortion to them?

Is there a way to pass a distorted <x,y,z> to those patterns? Something like
this?

  pigment {
    checker (invergence(<x,y,z>)) // Passing distorted <x,y,z> to Checker
    ...

  Steve


Post a reply to this message

From: SharkD
Subject: Re: Nonlinear distortion of <x,y,z> possible?
Date: 7 Jul 2008 15:40:01
Message: <web.487270549a281388f7bf1c280@news.povray.org>
"slehar" <sle### [at] gmailcom> wrote:
> But neither of the three will allow me to use pre-defined patterns such as
> checker, wood, brick, hexagon, and apply a distortion to them, will they? So I
> would have to re-write the code for those patterns in order to apply the
> distortion to them?

See the Step Function tutorial in the wiki for an example of how to modify
existing functions.

http://wiki.povray.org/content/HowTo:Turn_a_function_into_a_stepped_function

-Mike


Post a reply to this message

From: Chris B
Subject: Re: Nonlinear distortion of <x,y,z> possible?
Date: 7 Jul 2008 16:06:44
Message: <48727754@news.povray.org>
"slehar" <sle### [at] gmailcom> wrote in message 
news:web.48726e7c9a281388f75a90cb0@news.povray.org...
>
>
> But neither of the three will allow me to use pre-defined patterns such as
> checker, wood, brick, hexagon, and apply a distortion to them, will they? 
> So I
> would have to re-write the code for those patterns in order to apply the
> distortion to them?
>
> Is there a way to pass a distorted <x,y,z> to those patterns? Something 
> like
> this?
>
>  pigment {
>    checker (invergence(<x,y,z>)) // Passing distorted <x,y,z> to Checker
>    ...

You can use a pre-defined pattern such as checker, wood, brick etc. in a 
function. You can then mathematically distort the function and use the 
resulting function in a pigment. I see that SharkD has provided a link to a 
wiki page that describes that sort of approach, albeit to achieve a somewhat 
different result.

I just wanted to throw into the discussion the idea of using the black_hole 
warp, which can give you a visual effect that is somewhat similar to the 
image of a striped cylinder that you linked to. It should be a lot simpler 
to implement if you just need it to illustrate a story, but may not be 
sufficiently mathematicaly accurate for your needs.

Regards,
Chris B.


Post a reply to this message

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