Home | History | Annotate | Download | only in dvr
      1 #ifndef ANDROID_DVR_LOG_HELPERS_H_
      2 #define ANDROID_DVR_LOG_HELPERS_H_
      3 
      4 #include <iomanip>
      5 #include <ostream>
      6 
      7 #include <private/dvr/eigen.h>
      8 #include <private/dvr/field_of_view.h>
      9 
     10 namespace android {
     11 namespace dvr {
     12 
     13 template <typename T>
     14 inline std::ostream& operator<<(std::ostream& out,
     15                                 const Eigen::Vector<T, 2>& vec) {
     16   return out << "vec2(" << vec.x() << ',' << vec.y() << ')';
     17 }
     18 
     19 template <typename T>
     20 inline std::ostream& operator<<(std::ostream& out,
     21                                 const Eigen::Vector<T, 3>& vec) {
     22   return out << "vec3(" << vec.x() << ',' << vec.y() << ',' << vec.z() << ')';
     23 }
     24 
     25 template <typename T>
     26 inline std::ostream& operator<<(std::ostream& out,
     27                                 const Eigen::Vector<T, 4>& vec) {
     28   return out << "vec4(" << vec.x() << ',' << vec.y() << ',' << vec.z() << ','
     29              << vec.w() << ')';
     30 }
     31 
     32 template <typename T>
     33 inline std::ostream& operator<<(std::ostream& out,
     34                                 const Eigen::AffineMatrix<T, 4>& mat) {
     35   out << std::setfill(' ') << std::setprecision(4) << std::fixed
     36       << std::showpos;
     37   out << "\nmat4[";
     38   out << std::setw(10) << mat(0, 0) << " " << std::setw(10) << mat(0, 1) << " "
     39       << std::setw(10) << mat(0, 2) << " " << std::setw(10) << mat(0, 3);
     40   out << "]\n    [";
     41   out << std::setw(10) << mat(1, 0) << " " << std::setw(10) << mat(1, 1) << " "
     42       << std::setw(10) << mat(1, 2) << " " << std::setw(10) << mat(1, 3);
     43   out << "]\n    [";
     44   out << std::setw(10) << mat(2, 0) << " " << std::setw(10) << mat(2, 1) << " "
     45       << std::setw(10) << mat(2, 2) << " " << std::setw(10) << mat(2, 3);
     46   out << "]\n    [";
     47   out << std::setw(10) << mat(3, 0) << " " << std::setw(10) << mat(3, 1) << " "
     48       << std::setw(10) << mat(3, 2) << " " << std::setw(10) << mat(3, 3);
     49   out << "]\n";
     50 
     51   return out;
     52 }
     53 
     54 inline std::ostream& operator<<(std::ostream& out, const FieldOfView& fov) {
     55   return out << "fov(" << (fov.GetLeft() * 180.0f / M_PI) << ','
     56              << (fov.GetRight() * 180.0f / M_PI) << ','
     57              << (fov.GetBottom() * 180.0f / M_PI) << ','
     58              << (fov.GetTop() * 180.0f / M_PI) << ')';
     59 }
     60 
     61 }  // namespace dvr
     62 }  // namespace android
     63 
     64 #endif  // ANDROID_DVR_LOG_HELPERS_H_
     65