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
6 Aug 2024 16:55:15 EDT (-0400)
  Re: simulating lens distortion with normal and function in 3.5  
From: Bill Brehm
Date: 26 Feb 2002 19:51:56
Message: <3c7c2dac@news.povray.org>
Mike, thanks for all your help. Unfortunately, if I can't figure out how to
solve the the symmetry problem, I won't be able to use povray to simulate
lens distortion for high accuracy tests. But I did learn a lot. Thanks,
again. Bill


"Mike Williams" <mik### [at] nospamplease> wrote in message
news:emU### [at] econymdemoncouk...
> 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.