POV-Ray : Newsgroups : povray.binaries.images : Method to apply transforms to user_defined camera. : Re: Method to apply transforms to user_defined camera. Server Time
23 Apr 2024 16:36:47 EDT (-0400)
  Re: Method to apply transforms to user_defined camera.  
From: IGM
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

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