POV-Ray : Newsgroups : povray.general : simulating lens distortion with normal and function in 3.5 : Re: simulating lens distortion with normal and function in 3.5 Server Time
19 Nov 2024 13:27:07 EST (-0500)
  Re: simulating lens distortion with normal and function in 3.5  
From: Mike Williams
Date: 26 Feb 2002 13:54:16
Message: <emUwGEAgj9e8EwJe@econym.demon.co.uk>
Wasn't it Bill Brehm who wrote:
>Mike,
>
>1. I cannot use square images, but was able to modify the function to give
>symmetrical results. I'm curious how you found the Z value experimentally,
>if you wouldn't mind explaining. I might have to confirm if it ever changes
>for different camera parameters.

I tried these two functions

#declare lens_dist = function(x, y, z, a, b) {
   select (z-0.017, 1, 1/x) }

#declare lens_dist = function(x, y, z, a, b) {
   select (z-0.016, 1, 1/x) }

Note: "select()" is like an "#if" that works inside a function{}. It's
the same as saying 
        if ((z-0.016)<0) then 1 else 1/x

With z-0.017 (or any higher numbers) I get the undistorted picture which
indicates that "1" was selected. With z-0.016 (or any lower numbers) I
get a very distorted picture because "1/x" is being selected. Therefore
the z value being tested during the camera normal is somewhere between
0.016 and 0.017.

I used the same trick (with select x+-K and select z+-K) to determine
that the edges of the image are at +-0.5 in the x any y directions.


>I think the normal does some kind of approximate calculation. Try rendering
>the code below and you'll see that the rendered image is not symmetrical,
>even though everything in the code is symmetrical.
>
>#declare lens_dist = function(x, y, a, b) {
>   (x + a * x * sqrt(x*x + y*y) + b * x^3 * sqrt(x*x + y*y) ) ^ 2 + (y + a *
>y * sqrt(x*x + y*y) + b * y^3 * sqrt(x*x + y*y) ) ^ 2
>}
>
>#declare a_factor = 0.69;
>#declare b_factor = 0.1;
>
>camera {
>
>  location <0, 0, -100>
>  look_at <0, 0, 0>
>  right <4/4, 0, 0>
>
>  normal{function {lens_dist(x, y, a_factor, b_factor)} }
>}
>
>light_source { <0, 0, -100> color rgb <1, 1, 1> }
>
>plane{-z, -10 pigment{color rgb <0, 0, 1>}}
>
>box{<-25, -25, 0>, <25, 25, 0> pigment {color rgb <1, 0, 0>}}

Now that is weird.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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