Home | History | Annotate | Download | only in dvr
      1 #ifndef ANDROID_DVR_ORTHO_H_
      2 #define ANDROID_DVR_ORTHO_H_
      3 
      4 #include <private/dvr/types.h>
      5 
      6 namespace android {
      7 namespace dvr {
      8 
      9 template <class T>
     10 Eigen::AffineMatrix<T, 4> OrthoMatrix(T left, T right, T bottom, T top,
     11                                       T znear, T zfar) {
     12   Eigen::AffineMatrix<T, 4> result;
     13   const T t2 = static_cast<T>(2);
     14   const T a = t2 / (right - left);
     15   const T b = t2 / (top - bottom);
     16   const T c = t2 / (zfar - znear);
     17   const T xoff = -(right + left) / (right - left);
     18   const T yoff = -(top + bottom) / (top - bottom);
     19   const T zoff = -(zfar + znear) / (zfar - znear);
     20   const T t1 = static_cast<T>(1);
     21   result.matrix() << a, 0, 0, xoff,
     22             0, b, 0, yoff,
     23             0, 0, c, zoff,
     24             0, 0, 0, t1;
     25   return result;
     26 }
     27 
     28 }  // namespace android
     29 }  // namespace dvr
     30 
     31 #endif  // ANDROID_DVR_ORTHO_H_
     32