Ion
|
Encapsulates a generalized, asymmetric field of view with four half angles. More...
#include "fieldofview.h"
Public Member Functions | |
FieldOfView () | |
The default constructor sets an angle of 0 (in any unit) for all four half-angles. More... | |
FieldOfView (const Angle< T > &left, const Angle< T > &right, const Angle< T > &bottom, const Angle< T > &top) | |
Constructs a FieldOfView from four angles. More... | |
template<typename U > | |
FieldOfView (const FieldOfView< U > &fov) | |
Copy constructor from an instance of the same Dimension and any value type that is compatible (via static_cast) with this instance's type. More... | |
bool | SetFromTotalFovAndOpticalCenter (const Angle< T > fov_x, const Angle< T > fov_y, const Point< 2, T > &optical_center_ndc) |
Resets the FieldOfView based on a total field of view in both dimensions, and an optical center for the projection. More... | |
Point< 2, T > | GetOpticalCenter () const |
Returns the optical center of a projection that is created using this FieldOfView. More... | |
Matrix< 4, T > | GetProjectionMatrix (T near_p, T far_p) const |
Computes the projection matrix corresponding to the frustum defined by the four half angles and the two planes near_p and far_p . More... | |
Angle< T > | GetLeft () const |
Accessors for all four half-angles. More... | |
Angle< T > | GetRight () const |
Angle< T > | GetBottom () const |
Angle< T > | GetTop () const |
void | SetLeft (const Angle< T > &left) |
Setters for all four half-angles. More... | |
void | SetRight (const Angle< T > &right) |
void | SetBottom (const Angle< T > &bottom) |
void | SetTop (const Angle< T > &top) |
Angle< T > | GetCenteredFovX () const |
Gets the centered FOV in each dimension. More... | |
Angle< T > | GetCenteredFovY () const |
void | Print (std::ostream &out) const |
This is used for printing FOV objects to a stream. More... | |
void | Read (std::istream &in) |
This is used for reading FOV objects from a stream. More... | |
bool | IsZero () const |
Returns true iff all four angles are zero (which is the case after using the default constructor). More... | |
Static Public Member Functions | |
static FieldOfView< T > | FromProjectionMatrix (const Matrix< 4, T > &matrix) |
Constructs a FieldOfView by extracting the four frustum planes from the projection matrix. More... | |
static FieldOfView< T > | FromTangents (const T &left, const T &right, const T &bottom, const T &top) |
Constructs a FieldOfView from four values tan(alpha) for each half-angle alpha. More... | |
p_ndc **static FieldOfView< T > | FromCenteredFovAndOpticalCenter (const Angle< T > centered_fov_x, const Angle< T > centered_fov_y, const Point< 2, T > &optical_center_ndc) |
Constructs a FieldOfView based on a centered field of view and an optical center for the projection. More... | |
Friends | |
bool | operator== (const FieldOfView &fov0, const FieldOfView &fov1) |
Exact equality and inequality comparisons. More... | |
bool | operator!= (const FieldOfView &fov0, const FieldOfView &fov1) |
Encapsulates a generalized, asymmetric field of view with four half angles.
Each half angle denotes the angle between the corresponding frustum plane. Together with a near and far plane, a FieldOfView forms the frustum of an off-axis perspective projection.
Definition at line 36 of file fieldofview.h.
|
inline |
The default constructor sets an angle of 0 (in any unit) for all four half-angles.
Definition at line 183 of file fieldofview.h.
|
inline |
Constructs a FieldOfView from four angles.
Definition at line 186 of file fieldofview.h.
|
explicit |
Copy constructor from an instance of the same Dimension and any value type that is compatible (via static_cast) with this instance's type.
Definition at line 229 of file fieldofview.h.
|
inlinestatic |
Constructs a FieldOfView based on a centered field of view and an optical center for the projection.
The optical center is defined as the intersection of the optical axis with the image plane. Note that the optical center is invariant in world space. This method sets left/right/up/down so that the optical center appears at the given optical_center_ndc
with respect to the window defined by those bounds.
The centered FOV is not necessarily the actual FOV. It is defined as what the fov would be if the camera were kept the same perpendicular distance from the viewing plane but the optical center were the center of the screen.+–—*——*------——+ \ \ | | / \ | | ///< \ |\ | / / \ | \ |/ / | / |/ eye eye_centered
In the diagram above, the centered_fov is the angle at eye_centered. The centered FOV allows us to maintain the size of objects on the map.
Definition at line 352 of file fieldofview.h.
|
inlinestatic |
Constructs a FieldOfView by extracting the four frustum planes from the projection matrix.
Definition at line 212 of file fieldofview.h.
|
inlinestatic |
Constructs a FieldOfView from four values tan(alpha) for each half-angle alpha.
Definition at line 201 of file fieldofview.h.
References ion::math::Angle< T >::FromRadians().
|
inline |
Definition at line 117 of file fieldofview.h.
Angle<T> ion::math::FieldOfView< T >::GetCenteredFovX | ( | ) | const |
Gets the centered FOV in each dimension.
It is defined as what the FOV would be if the camera were kept the same perpendicular distance from the viewing plane but the optical center were the center of the screen.
|
inline |
Definition at line 422 of file fieldofview.h.
References ion::math::Angle< T >::FromRadians().
|
inline |
Accessors for all four half-angles.
Definition at line 115 of file fieldofview.h.
|
inline |
Returns the optical center of a projection that is created using this FieldOfView.
Definition at line 236 of file fieldofview.h.
|
inline |
Computes the projection matrix corresponding to the frustum defined by the four half angles and the two planes near_p
and far_p
.
Definition at line 191 of file fieldofview.h.
References ion::math::PerspectiveMatrixFromFrustum().
|
inline |
Definition at line 116 of file fieldofview.h.
|
inline |
Definition at line 118 of file fieldofview.h.
|
inline |
Returns true iff all four angles are zero (which is the case after using the default constructor).
Definition at line 478 of file fieldofview.h.
|
inline |
This is used for printing FOV objects to a stream.
Definition at line 431 of file fieldofview.h.
Referenced by ion::math::operator<<().
|
inline |
This is used for reading FOV objects from a stream.
Definition at line 437 of file fieldofview.h.
References ion::base::GetExpectedChar(), and ion::base::GetExpectedString().
Referenced by ion::math::operator>>().
|
inline |
Definition at line 123 of file fieldofview.h.
|
inline |
Resets the FieldOfView based on a total field of view in both dimensions, and an optical center for the projection.
The optical center is defined as the intersection of the optical axis with the image plane. Note that the optical center is invariant in world space. This method sets left/right/up/down so that the optical center appears at the given optical_center_ndc
with respect to the window defined by those bounds.
Returns true if a valid configuration was provided. If the provided configuration was invalid, the FieldOfView object remains unchanged and this method returns false.
Definition at line 249 of file fieldofview.h.
|
inline |
Setters for all four half-angles.
Definition at line 121 of file fieldofview.h.
|
inline |
Definition at line 122 of file fieldofview.h.
|
inline |
Definition at line 124 of file fieldofview.h.
|
friend |
Definition at line 148 of file fieldofview.h.
|
friend |
Exact equality and inequality comparisons.
Definition at line 144 of file fieldofview.h.