POV-Ray : Newsgroups : povray.binaries.images : Method to apply transforms to user_defined camera. Server Time: 30 Mar 2020 14:19:54 GMT
 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 23:36:01 Message: <5cec7461@news.povray.org>
```On the povray.general group and in the recent thread:

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.
```

Attachments:

Preview of image 'udefcamera_transform.png'

 From: IGM Subject: Re: Method to apply transforms to user_defined camera. Date: 30 May 2019 15:55:01 Message:
```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...

#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 }
}
```
 From: William F Pokorny Subject: Re: Method to apply transforms to user_defined camera. Date: 30 May 2019 22: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:
>
>
> 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:

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.
```
 From: Mike Horvath Subject: Re: Method to apply transforms to user_defined camera. Date: 31 May 2019 01: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:
>
>
>
> 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
```