POV-Ray : Newsgroups : povray.binaries.images : Method to apply transforms to user_defined camera. Server Time
28 Mar 2024 08:54:49 EDT (-0400)
  Method to apply transforms to user_defined camera. (Message 1 to 4 of 4)  
From: William F Pokorny
Subject: Method to apply transforms to user_defined camera.
Date: 27 May 2019 19:36:01
Message: <5cec7461@news.povray.org>
On the povray.general group and in the recent thread:

http://news.povray.org/povray.general/thread/%3C5ce2a3dd%241%40news.povray.org%3E/

IGM / igmar asked about applying transforms to user_defined cameras. The 
documentation implies transform modifiers can be applied, but this is 
not the case in v38 as of today.

The following modification to the shipped user_defined.pov camera scene 
works - as far as it goes - as a way to apply transforms to the user 
defined cameras.

#declare Fxfrm = function {
     transform {              // Given use below:
         rotate <50, 0, 0>    // Stuff happens. Sometimes OK
      // translate <0.1,0,0>  // Stuff happens. Sometimes OK
      // scale 2.0            // 1.0 0.5 2.0 -1.0  Always OK
     }
}

//------- Set up functional camera
#declare FnXrad = function (x) { (x+0.5)*tau }
#declare FnX    = function (x) { cos(FnXrad(x)) }
#declare FnZ    = function (x) { sin(FnXrad(x)) }
#declare CameraUserDefined = camera {
     user_defined
     location {
       function { Fxfrm(FnX(x),0,0).x }
       function { Fxfrm(0,y,0).y }
       function { Fxfrm(0,0,FnZ(x)).z }
     }
     direction {
       function { Fxfrm(-FnX(x),0,0).x }
       function { Fxfrm(0,0,0).y }
       function { Fxfrm(0,0,-FnZ(x)).z }
     }
}

For some user cameras and transforms might be just whats needed. See the 
attached image for some results. For more complex situations, especially 
with rotation, we'd need to handle/re-map the modified vector's x,y,z 
components from all the modified original vectors back into the 
appropriate x,y,z inputs for location and direction. My head is too 
tired to handle that bit at the moment...

Bill P.


Post a reply to this message


Attachments:
Download 'udefcamera_transform.png' (71 KB)

Preview of image 'udefcamera_transform.png'
udefcamera_transform.png


 

From: IGM
Subject: Re: Method to apply transforms to user_defined camera.
Date: 30 May 2019 11:55:01
Message: <web.5ceffc57eb2db81e776fc67d0@news.povray.org>
The following code allows to reproduce optical distortion
(https://en.wikipedia.org/wiki/Distortion_(optics)#Software_correction). I think
this could be useful for several PovRay users. Unfortunately I still do not know
how to do couple this code with the transform functions by Bill. Any idea?
I miss a formal definition of "location" and "direction" directives arguments,
or maybe I don't have enough experience using the PovRay "function" block...

// Radial distortion coefficients
#declare k1 = 2;
#declare k2 = -1;
#declare k3 = 0;

#declare AR = image_width/image_height; // Aspect ratio

camera {
    user_defined
    location  <0,0,0>
    direction {
      function { AR*x + AR*x*(
        k1*(pow(AR*x,2)+pow(y,2)) +
        k2*pow(pow(AR*x,2)+pow(y,2),2) +
        k3*pow(pow(AR*x,2)+pow(y,2),4)
        ) }
      function { y + y*(
        k1*(pow(AR*x,2)+pow(y,2)) +
        k2*pow(pow(AR*x,2)+pow(y,2),2) +
        k3*pow(pow(AR*x,2)+pow(y,2),4)
        )}
      function { 1 }
}


Post a reply to this message

From: William F Pokorny
Subject: Re: Method to apply transforms to user_defined camera.
Date: 30 May 2019 18:43:13
Message: <5cf05c81$1@news.povray.org>
On 5/27/19 7:36 PM, William F Pokorny wrote:
> On the povray.general group and in the recent thread:
> 
> http://news.povray.org/povray.general/thread/%3C5ce2a3dd%241%40news.povray.org%3E/ 
> 
> IGM / igmar asked about applying transforms to user_defined cameras. The 
> documentation implies transform modifiers can be applied, but this is 
> not the case in v38 as of today.
> 
> The following modification to the shipped user_defined.pov camera scene 
> works - as far as it goes - as a way to apply transforms to the user 
> defined cameras.
...
> 

In turning to look at this again while my tea brews I found the thread:

http://news.povray.org/povray.general/thread/%3CXnsA9E3A3F647A49seed7%40news.povray.org%3E/

via a pointer from Bald Eagle where Tor Olav Kristensen, ingo, et al. 
got well beyond anything I have in my head both for the problems 
involved and solutions for transforming a user defined camera. Sorry 
igmar - and all - I managed to miss this work. I've just spun folks 
around I think...

Bill P.


Post a reply to this message

From: Mike Horvath
Subject: Re: Method to apply transforms to user_defined camera.
Date: 30 May 2019 21:15:33
Message: <5cf08035$1@news.povray.org>
On 5/27/2019 7:36 PM, William F Pokorny wrote:
> On the povray.general group and in the recent thread:
> 
> http://news.povray.org/povray.general/thread/%3C5ce2a3dd%241%40news.povray.org%3E/ 
> 
> 
> IGM / igmar asked about applying transforms to user_defined cameras. The 
> documentation implies transform modifiers can be applied, but this is 
> not the case in v38 as of today.
> 
> The following modification to the shipped user_defined.pov camera scene 
> works - as far as it goes - as a way to apply transforms to the user 
> defined cameras.
> 
> #declare Fxfrm = function {
>      transform {              // Given use below:
>          rotate <50, 0, 0>    // Stuff happens. Sometimes OK
>       // translate <0.1,0,0>  // Stuff happens. Sometimes OK
>       // scale 2.0            // 1.0 0.5 2.0 -1.0  Always OK
>      }
> }
> 
> //------- Set up functional camera
> #declare FnXrad = function (x) { (x+0.5)*tau }
> #declare FnX    = function (x) { cos(FnXrad(x)) }
> #declare FnZ    = function (x) { sin(FnXrad(x)) }
> #declare CameraUserDefined = camera {
>      user_defined
>      location {
>        function { Fxfrm(FnX(x),0,0).x }
>        function { Fxfrm(0,y,0).y }
>        function { Fxfrm(0,0,FnZ(x)).z }
>      }
>      direction {
>        function { Fxfrm(-FnX(x),0,0).x }
>        function { Fxfrm(0,0,0).y }
>        function { Fxfrm(0,0,-FnZ(x)).z }
>      }
> }
> 
> For some user cameras and transforms might be just whats needed. See the 
> attached image for some results. For more complex situations, especially 
> with rotation, we'd need to handle/re-map the modified vector's x,y,z 
> components from all the modified original vectors back into the 
> appropriate x,y,z inputs for location and direction. My head is too 
> tired to handle that bit at the moment...
> 
> Bill P.


Are there examples on the web of all the weird stuff you could do with a 
user defined camera? IIRC someone created a scene years ago of how the 
relativistic effects of a fast moving vehicle can change what you see, 
from both the viewpoint of the passenger and the bystander. Would a user 
defined camera help here?


Michael


Post a reply to this message

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