Collaboration diagram for Archon::Display::Test::PerspectiveProjection:
Public Member Functions | |
PerspectiveProjection (double horizontalDotPitch=0.0254/96, double verticalDotPitch=0.0254/96, double viewDistance=0.4, double aspectRatio=1, double neutralFieldOfView=0.828427124747, double farToNearClipRatio=100, double zoomFactor=1, double cameraDistance=10) | |
Construct a perspective projection. | |
double | getHorizontalResolutionDpcm () |
Get the horizontal resolution of the screen measured in dots per centimeter. | |
double | getVerticalResolutionDpcm () |
Get the vertical resolution of the screen measured in dots per centimeter. | |
void | setResolutionDpcm (double h, double v) |
Set the resolution of your screen as dots per centimeter. | |
double | getHorizontalResolutionDpi () |
Get the horizontal resolution of the screen measured in dots per inch. | |
double | getVerticalResolutionDpi () |
Get the vertical resolution of the screen measured in dots per inch. | |
void | setResolutionDpi (double h, double v) |
Set the resolution of your screen as dots per inch. | |
double | getViewportWidthMeters () |
int | getViewportWidthPixels () |
double | getViewportHeightMeters () |
int | getViewportHeightPixels () |
void | setViewportSizeMeters (double width, double height) |
void | setViewportSizePixels (int width, int height) |
double | getNearClipDist () |
Get the distance from the center of projection to the near clipping plane. | |
double | getFarClipDist () |
Get the distance from the center of projection to the far clipping plane. | |
double | getNearClipWidth () |
Get the width of the image as it is when projected onto a view plane at the near clipping distance. | |
double | getNearClipHeight () |
Get the height of the image as it is when projected onto a view plane at the near clipping distance. | |
void | autoDistance (double interest, double f=1) |
Move the camera to a distance where the sphere of interest fits perfectly within the field of view, or equivalently, where the projection of the sphere of interest fits perfectly inside the viewport. | |
void | autoZoom (double interest, double f=1) |
Adjust the zoom factor such that the sphere of interest fits perfectly within the field of view, or equivalently, such that the projection of the sphere of interest fits perfectly inside the viewport. | |
double | getActualHorizontalFieldOfView () |
Get the width of the image when projected onto a view plane at distance 1 from the center of projection. | |
double | getActualVerticalFieldOfView () |
Get the height of the image when projected onto a view plane at distance 1 from the center of projection. | |
double | getNeutralSolidAngleOfView () |
Get the solid angle corresponding with the neutral field of view of the camera. | |
void | setNeutralSolidAngleOfView (double v) |
Modify the neutral field of view of the camera in terms of solid angle of view. | |
double | getActualSolidAngleOfView () |
Get the solid angle corresponding with the actual field of view of the camera. | |
void | setActualSolidAngleOfView (double v) |
Modify the actual field of view of the camera in terms of solid angle of view. | |
double | getNeutralAngleOfView (double f=1) |
Get the angle of view corresponding with the neutral field of view of the camera. | |
void | setNeutralAngleOfView (double v, double f=1) |
Set the neutral field of view of the camera to correspond with the specified angle of view. | |
double | getActualAngleOfView (double f=1) |
Get the angle of view corresponding with the actual field of view of the camera. | |
void | setActualAngleOfView (double v, double f=1) |
Set the actual field of view of the camera to correspond with the specified angle of view. | |
double | getMeanFieldFactor () |
Use with getAngleOfView/setAngleOfView to get/set the mean angle of view. | |
double | getHorizontalFieldFactor () |
Use with getAngleOfView/setAngleOfView to get/set the horizontal angle of view. | |
double | getVerticalFieldFactor () |
Use with getAngleOfView/setAngleOfView to get/set the vertical angle of view. | |
double | getDiagonalFieldFactor () |
Use with getAngleOfView/setAngleOfView to get/set the diagonal angle of view. | |
double | getMinimumFieldFactor () |
Use with getAngleOfView/setAngleOfView to get/set the minimum angle of view. | |
double | getMaximumFieldFactor () |
Use with getAngleOfView/setAngleOfView to get/set the maximum angle of view. | |
Public Attributes | |
double | horizontalDotPitch |
Horizontal distance between pixels on the viewport (eg. | |
double | verticalDotPitch |
Vertical distance between pixels on the viewport (eg. | |
double | viewDistance |
Distance along the optical axis from your eyes to the viewport measured in meters. | |
double | aspectRatio |
Ratio of image width to image height on view plane. | |
double | neutralFieldOfView |
The neutral field of view of the camera. | |
double | farToNearClipRatio |
Ratio of far clipping distance to near clipping distance. | |
double | zoomFactor |
Together with the neutral field of view the zoom factor determines the actual field of view of the camera. | |
double | cameraDistance |
Distance from center of projection to center of interest. |
The projection is modeled as a set of independant parameters, each one carefully chosen to ease its interpretation in terms of well known physical quantities.
To understand the camera model one must think of a rectangular box. At the center of the front face there is a small hole (center of projection) where light rays enter the box. These rays project an image onto the opposite face of the box (view plane). The width and height of the box relative to the depth of the box defines the field of view of the camera.
The viewport is the flat rectangular area on the screen in which the projected image is displayed.
The view distance is the distance from your eyes to the viewport along an axis that is perpendicular to the viewport.
The view plane is a plane perpenndicular to the optical axis onto which the...
Definition at line 285 of file render.C.
|
Construct a perspective projection.
|
|
Move the camera to a distance where the sphere of interest fits perfectly within the field of view, or equivalently, where the projection of the sphere of interest fits perfectly inside the viewport. The precise meaning of a perfect fit is determined by the field factor (see below.) This operation basically allows you to control how big your scene will look on your screen while at the same time giving you full control over the perspective in the projected image as experienced by you. In particular if the zoom factor is set to 1 and the neutral field of view of the camera is correctly specified to match the field of view experienced by you when you look "through" the viewport on your screen and the aspect ratio of the camera is correctly specified to match the aspect ratio of the viewport, then the perspective in the image you see will be perfect. That is, sheres will appear spheric (not elliptic) and cubes will look cubic (not rectangular). By default (f=1) the sphere of interest will be fitted to the mean field of view meaning that the diameter of the projection will be equal to the geometric mean between the with and the height of the vewport. One can obtain other fits by specifying other values for the field factor f. For example setting f = getHorizontalFieldFactor() will result in a diameter equal to the width of the viewport while f = getDiagonalFieldFactor() will result in a diameter equal to the diameter of the viewport.
Definition at line 667 of file render.C. References cameraDistance, neutralFieldOfView, Archon::Math::sq(), and zoomFactor. Referenced by Archon::Display::Test::resize(). |
|
Adjust the zoom factor such that the sphere of interest fits perfectly within the field of view, or equivalently, such that the projection of the sphere of interest fits perfectly inside the viewport. The precise meaning of a perfect fit is determined by the field factor (see below.) This operation basically allows you to control how big your scene will look on your screen while at the same time keeping the camera distance fixed. Unlike in the case of autoDistance the resulting perspective in the image you see will be distorted by the zooming and sometimes even heavily distorted. Spheres will appear elliptical and cubes will look rectangular. On the other hand, if the position of your camera is controlled in ways that cannot be interfeared with, this is the only way to acheive the fitting effect. By default (f=1) the sphere of interest will be fitted to the mean field of view meaning that the diameter of the projection will be equal to the geometric mean between the with and the height of the vewport. One can obtain other fits by specifying other values for the field factor f. For example setting f = getHorizontalFieldFactor() will result in a diameter equal to the width of the viewport while f = getDiagonalFieldFactor() will result in a diameter equal to the diameter of the viewport.
Definition at line 710 of file render.C. References cameraDistance, neutralFieldOfView, Archon::Math::sq(), and zoomFactor. |
|
Get the angle of view corresponding with the actual field of view of the camera. That is, the angle of view with the zoom factor applied. By default (f=1) the returned angle is the mean angle of view. See getMeanFieldFactor for the definition of mean angle of view. One can obtain other flavors of the angle of view by specifying other values for the field factor f. For example setting f = getHorizontalFieldFactor() will produce the horizontal angle of view while f = getDiagonalFieldFactor() will produce the diagonal angle of view.
Definition at line 884 of file render.C. References neutralFieldOfView, and zoomFactor. |
|
Get the width of the image when projected onto a view plane at distance 1 from the center of projection.
Definition at line 723 of file render.C. References getHorizontalFieldFactor(), neutralFieldOfView, and zoomFactor. Referenced by getNearClipWidth(), and getViewportWidthMeters(). |
|
Get the solid angle corresponding with the actual field of view of the camera. That is, the angle of view with the zoom factor applied. The solid angle of view is defined as the area of the projection of the image onto the unit sphere.
Definition at line 788 of file render.C. References aspectRatio, neutralFieldOfView, Archon::Math::sq(), and zoomFactor. |
|
Get the height of the image when projected onto a view plane at distance 1 from the center of projection.
Definition at line 734 of file render.C. References getVerticalFieldFactor(), neutralFieldOfView, and zoomFactor. Referenced by getNearClipHeight(), and getViewportHeightMeters(). |
|
Use with getAngleOfView/setAngleOfView to get/set the diagonal angle of view. The diagonal angle of view is defined as the angle subtended at the center of projection by the diagonal of the image on the view plane.
Definition at line 975 of file render.C. References aspectRatio. |
|
Get the distance from the center of projection to the far clipping plane. Use this quantity in the specification of the view frustum of your rendering API (eg. glFrustum.) See getNearClipDist for further details.
Definition at line 585 of file render.C. References farToNearClipRatio, and getNearClipDist(). Referenced by Archon::Display::Test::resize(). |
|
Use with getAngleOfView/setAngleOfView to get/set the horizontal angle of view. The horizontal angle of view is defined as the angle subtended at the center of projection by a line segment running from the midpoint of the left edge to the midpoint of the right edge of the image on the view plane.
Definition at line 944 of file render.C. References aspectRatio. Referenced by getActualHorizontalFieldOfView(). |
|
Get the horizontal resolution of the screen measured in dots per centimeter.
Definition at line 449 of file render.C. References horizontalDotPitch. |
|
Get the horizontal resolution of the screen measured in dots per inch.
Definition at line 485 of file render.C. References horizontalDotPitch. |
|
Use with getAngleOfView/setAngleOfView to get/set the maximum angle of view. The maximum angle of view is defined as being either the horizontal or the vertical angle of view whichever is largest.
Definition at line 1005 of file render.C. References aspectRatio. |
|
Use with getAngleOfView/setAngleOfView to get/set the mean angle of view. The mean angle of view is defined as the angle subtended at the center of projection by a line segment lying centered on the view plane and whose length is equal to the geometric mean between the with and the height of the image when projected onto that view plane.
|
|
Use with getAngleOfView/setAngleOfView to get/set the minimum angle of view. The minimum angle of view is defined as being either the horizontal or the vertical angle of view whichever is smallest.
Definition at line 990 of file render.C. References aspectRatio. Referenced by Archon::Display::Test::resize(). |
|
Get the distance from the center of projection to the near clipping plane. Use this quantity in the specification of the view frustum of your rendering API (eg. glFrustum.) The near and far clipping distances are both function of the camera distance and the requested far to near distance ratio. They are determined such that the camera distance is equal to the geometric mean between the near and the far clipping distances and such that the requested ratio between the near and the far clipping distances is maintained. This particular way of determining the clipping distances is simple and seems to fit most needs, but of course there are many other ways of doing it.
Definition at line 569 of file render.C. References cameraDistance, and farToNearClipRatio. Referenced by getFarClipDist(), getNearClipHeight(), getNearClipWidth(), and Archon::Display::Test::resize(). |
|
Get the height of the image as it is when projected onto a view plane at the near clipping distance. The height is determined by the actual field of view as well as the aspect ratio of the camera. Use this quantity in the specification of the view frustum of your rendering API (eg. glFrustum.)
Definition at line 621 of file render.C. References getActualVerticalFieldOfView(), and getNearClipDist(). Referenced by Archon::Display::Test::resize(). |
|
Get the width of the image as it is when projected onto a view plane at the near clipping distance. The width is determined by the actual field of view as well as the aspect ratio of the camera. Use this quantity in the specification of the view frustum of your rendering API (eg. glFrustum.)
Definition at line 603 of file render.C. References getActualHorizontalFieldOfView(), and getNearClipDist(). Referenced by Archon::Display::Test::resize(). |
|
Get the angle of view corresponding with the neutral field of view of the camera. By default (f=1) the returned angle is the mean angle of view. See getMeanFieldFactor for the definition of mean angle of view. One can obtain other flavors of the angle of view by specifying other values for the field factor f. For example setting f = getHorizontalFieldFactor() will produce the horizontal angle of view while f = getDiagonalFieldFactor() will produce the diagonal angle of view.
Definition at line 830 of file render.C. References neutralFieldOfView. |
|
Get the solid angle corresponding with the neutral field of view of the camera. The solid angle of view is defined as the area of the projection of the image onto the unit sphere.
Definition at line 751 of file render.C. References aspectRatio, neutralFieldOfView, and Archon::Math::sq(). |
|
Use with getAngleOfView/setAngleOfView to get/set the vertical angle of view. The vertical angle of view is defined as the angle subtended at the center of projection by a line segment running from the midpoint of the bootom edge to the midpoint of the top edge of the image on the view plane.
Definition at line 960 of file render.C. References aspectRatio. Referenced by getActualVerticalFieldOfView(). |
|
Get the vertical resolution of the screen measured in dots per centimeter.
Definition at line 460 of file render.C. References verticalDotPitch. |
|
Get the vertical resolution of the screen measured in dots per inch.
Definition at line 496 of file render.C. References verticalDotPitch. |
|
Set the actual field of view of the camera to correspond with the specified angle of view. This modifies only the zoom factor. The neutral field of view is left unchanged. The aspect ratio is maintained. By default (f=1) the specified angle is the mean angle of view. See getMeanFieldFactor for the definition of mean angle of view. One can specify other flavors of the angle of view by specifying other values for the field factor f. For example one can specyfy the horizontal angle of view by setting f = getHorizontalFieldFactor() or the diagonal angle of view with f = getDiagonalFieldFactor().
Definition at line 909 of file render.C. References neutralFieldOfView, and zoomFactor. |
|
Modify the actual field of view of the camera in terms of solid angle of view. This modifies only the zoom factor. The neutral field of view is left unchanged. The aspect ratio is maintained. The solid angle of view is defined as the area of the projection of the image onto the unit sphere.
Definition at line 805 of file render.C. References aspectRatio, neutralFieldOfView, Archon::Math::sq(), and zoomFactor. |
|
Set the neutral field of view of the camera to correspond with the specified angle of view. The aspect ratio is maintained. By default (f=1) the specified angle is the mean angle of view. See getMeanFieldFactor for the definition of mean angle of view. One can specify other flavors of the angle of view by specifying other values for the field factor f. For example one can specyfy the horizontal angle of view by setting f = getHorizontalFieldFactor() or the diagonal angle of view with f = getDiagonalFieldFactor(). You should generally specify a value here that is equal to the angle subtended at your eyes by the viewport on your screen. This guarantees an undistorted perception of perspective when the zoom factor of the camera is 1.
Definition at line 859 of file render.C. References neutralFieldOfView. |
|
Modify the neutral field of view of the camera in terms of solid angle of view. The aspect ratio is maintained. The solid angle of view is defined as the area of the projection of the image onto the unit sphere. You should generally specify a value here that is equal to the solid angle subtended at your eyes by the viewport on your screen. This guarantees an undistorted perception of perspective when the zoom factor of the camera is 1.
Definition at line 771 of file render.C. References aspectRatio, neutralFieldOfView, and Archon::Math::sq(). |
|
Set the resolution of your screen as dots per centimeter.
Definition at line 471 of file render.C. References horizontalDotPitch, and verticalDotPitch. |
|
Set the resolution of your screen as dots per inch.
Definition at line 507 of file render.C. References horizontalDotPitch, and verticalDotPitch. |
|
Horizontal distance between pixels on the viewport (eg. between pixel centers) measured in meters. Definition at line 291 of file render.C. Referenced by getHorizontalResolutionDpcm(), getHorizontalResolutionDpi(), getViewportWidthPixels(), Archon::Display::Test::main(), setResolutionDpcm(), setResolutionDpi(), and setViewportSizePixels(). |
|
The neutral field of view of the camera. That is, the field of view when the zoom factor is set to 1. The actual field of view of the camera is affected by the neutral field of view of the camera as well as the zoom factor. See 'zoomFactor' for further details on the actual field of view of the camera. To get a predictable perception of perspective while viewing the projected image on your screen, the neutral field of view of the camera should at all times be kept equal to the field of view inherent in the physical viewing condition. Thus, both the distance from your eyes to the screen and the size of the viewport affects the correct value for the neutral field of view of the camera. The most intuitive way of specifying the neutral field of view of the camera is to set 'viewDistance' to the the actual viewing distance and then call setViewportSizeMeters to specify the actual dimensions of the viewport. That said, this class offers numerous other ways of specifying the same thing. Keeping the neutral field of view of the camera equal to the field of view of the physical viewing condition guarantees a correct (undistorted) perception of perspective as long as the zoom factor is 1 (just as if the viewport had been a window into a space behind the screen.) The neutral field of view of the camera is defined as the geometric mean between the width and the height of the image as it would appear without zoom on a view plane at distance 1 from the center of projection. Definition at line 351 of file render.C. Referenced by autoDistance(), autoZoom(), getActualAngleOfView(), getActualHorizontalFieldOfView(), getActualSolidAngleOfView(), getActualVerticalFieldOfView(), getNeutralAngleOfView(), getNeutralSolidAngleOfView(), setActualAngleOfView(), setActualSolidAngleOfView(), setNeutralAngleOfView(), setNeutralSolidAngleOfView(), and setViewportSizeMeters(). |
|
Vertical distance between pixels on the viewport (eg. between pixel centers) measured in meters. Definition at line 297 of file render.C. Referenced by getVerticalResolutionDpcm(), getVerticalResolutionDpi(), getViewportHeightPixels(), Archon::Display::Test::main(), setResolutionDpcm(), setResolutionDpi(), and setViewportSizePixels(). |
|
Distance along the optical axis from your eyes to the viewport measured in meters. The optical axis is the line that runs through the midpoint between your eyes and is perpendicular to the viewport plane. the point of intersection with the viewport plane is called the pricipal point, and in the case of this simplified projection the pricipal point is always conincident with the center of the viewport. Definition at line 310 of file render.C. Referenced by getViewportHeightMeters(), getViewportWidthMeters(), Archon::Display::Test::main(), and setViewportSizeMeters(). |
|
Together with the neutral field of view the zoom factor determines the actual field of view of the camera. With a definition similar to that of the neutral field of view we get the following simple relation:
actualFieldOfView * zoomFactor = neutralFieldOfView
Thus setting zoomFactor to 1 means that camera will produce an image with an undistorted perspective, just as if the viewport had been a window into a space behind the screen, but only as long as the neutral field of view of the camera is correctly specified to match the field of view experienced by you when you look "through" the viewport on your screen and the aspect ratio of the camera is correctly specified to match the aspect ratio of the viewport. Setting the zoomFactor to 2 will produce an image where all features will appear twice as wide and twice as heigh as they would with zoomFactor = 1. At the same time there will be no apparant change to the depth of these objects, thus they will appear squeezed in that direction. This is the usual and well known (from photography) distortion of perspective caused by zooming. There is an interesting duality between zooming and 2-D scaling. If you capture an image with zoom factor set to 2, then scale it to half size (half width and half height) the the result will be indistinguishable from the image you get with zoom factor set to 1 and then cropping it uniformly to half size. In a sence zooming and 2-D scaling is the same thing. This is also a proof of the (for some, surprising) fact that 2-D scaling distorts the perspective of the scaled image. Definition at line 398 of file render.C. Referenced by autoDistance(), autoZoom(), getActualAngleOfView(), getActualHorizontalFieldOfView(), getActualSolidAngleOfView(), getActualVerticalFieldOfView(), getViewportHeightMeters(), getViewportWidthMeters(), setActualAngleOfView(), and setActualSolidAngleOfView(). |