POV-Ray : Newsgroups : povray.general : Reverse operation of camera code : Reverse operation of camera code Server Time
19 Apr 2024 23:41:31 EDT (-0400)
  Reverse operation of camera code  
From: Mike Horvath
Date: 23 Jun 2019 18:03:52
Message: <5d0ff748@news.povray.org>
Starting with location, look_at, angle and sky, I perform the following 
operations:

//--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---

#declare Camera_Location = <25.000000,15.000000,-33.000000>;
#declare Camera_Look_At = <2.000000,2.000000,0.000000>;
#declare Camera_Angle = 70.000000;
// should be able to set this to false as well
#declare Camera_Orthographic = true;

#local CamL = Camera_Location;
#local CamD = vnormalize(Camera_Look_At - CamL);
#local CamR = vnormalize(vcross(Camera_Sky, CamD));
#local CamU = vnormalize(vcross(CamD, CamR));
#local CamW = vlength(Camera_Look_At - CamL);

#if (Camera_Orthographic = true)
	#local CamR = CamR * CamW;
	#local CamU = CamU * CamW;
#end

#declare Camera_Zoom		= 1/2/tand(Camera_Angle/2) * Camera_Aspect_Ratio;
#declare Camera_Direction	= CamD * Camera_Zoom;
#declare Camera_Right		= CamR * Camera_Aspect_Ratio;
#declare Camera_Up			= CamU;

//--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---

The code calculates the values of the camera's direction, right and up.

My question is, how do I do the inverse? I.e. starting with location, 
direction, right and up, how do I calculate look_at, angle and sky? It 
seems like pretty simple algebra but I have been hitting my head against 
the wall trying to figure it out.

Thanks.


Michael


Post a reply to this message

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