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