Text archives Help
- From: roni@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1833 - trunk/Model/Cameras
- Date: Wed, 7 Nov 2007 16:18:59 -0700 (MST)
Author: roni
Date: Wed Nov 7 16:18:59 2007
New Revision: 1833
Modified:
trunk/Model/Cameras/PinholeCamera.cc
Log:
Model/Cameras/PinholeCamera.cc
Added "none" option to -maintainAspectRatio for completeness.
Fixed problem with Camera::KeepHorizontal mode- it requires
the inverse of the ratio used in the KeepVertical case.
Replaced manual degree-to-radian conversion with utility
function call.
Modified: trunk/Model/Cameras/PinholeCamera.cc
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.cc (original)
+++ trunk/Model/Cameras/PinholeCamera.cc Wed Nov 7 16:18:59 2007
@@ -87,6 +87,8 @@
aspectRatioMode = Camera::KeepHorizontal;
else if(keep == "vertical")
aspectRatioMode = Camera::KeepVertical;
+ else if(keep == "none")
+ aspectRatioMode = Camera::KeepNone;
else
throw IllegalArgument("PinholeCamera -maintainAspectRatio", i, args);
} else {
@@ -130,12 +132,15 @@
// This method modifies the "variable" fov to correctly reflect the
// aspect ratio passed in.
+ float realRatio = ratio;
+
const Real *inputAngle = 0;
Real *outputAngle = 0;
switch(aspectRatioMode){
case Camera::KeepHorizontal:
inputAngle = &hfov;
outputAngle = &vfov;
+ realRatio = 1./ratio;
break;
case Camera::KeepVertical:
@@ -148,7 +153,7 @@
break;
}
- *outputAngle = RtoD(2*atan(ratio*tan(DtoR(0.5*(*inputAngle)))));
+ *outputAngle = RtoD(2*atan(realRatio*tan(DtoR(0.5*(*inputAngle)))));
setup();
// Choudhury: This is a hack to solve the initially non-square image
@@ -187,11 +192,11 @@
u=Cross(v, direction);
u.normalize();
- height=nearZ*tan(vfov*(Real)(0.5*M_PI/180.0));
+ height=nearZ*tan(DtoR(0.5*vfov));
u*=height;
- width=nearZ*tan(hfov*(Real)(0.5*M_PI/180.0));
- v*=width;
+ width=nearZ*tan(DtoR(0.5*hfov));
+ v*=width;
}
void PinholeCamera::makeRays(const RenderContext& context, RayPacket& rays)
const
- [Manta] r1833 - trunk/Model/Cameras, roni, 11/07/2007
Archive powered by MHonArc 2.6.16.