Go to the documentation of this file.00001
00002 #ifndef vgui_projection_inspector_h_
00003 #define vgui_projection_inspector_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <vnl/vnl_double_2.h>
00015 #include <vnl/vnl_double_3.h>
00016 #include <vnl/vnl_double_4.h>
00017 #include <vnl/vnl_double_4x4.h>
00018 #include <vcl_iosfwd.h>
00019
00020
00021 class vgui_projection_inspector
00022 {
00023 public:
00024
00025 vgui_projection_inspector() { inspect(); }
00026
00027
00028 ~vgui_projection_inspector() {}
00029
00030
00031 vnl_double_4x4 const& projection_matrix() const { return P; }
00032
00033
00034 vnl_double_4x4 const& modelview_matrix() const { return M; }
00035
00036
00037 int const *viewport() const { return vp; }
00038
00039
00040 void print(vcl_ostream&) const;
00041
00042
00043 vnl_double_4x4 total_transformation() const { return P*M; }
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 bool diagonal_scale_3d;
00057
00058
00059 float x1;
00060
00061 float y1;
00062
00063 float x2;
00064
00065 float y2;
00066
00067 float s[3], t[3];
00068
00069
00070 void window_to_image_coordinates(int, int, float &,float &) const;
00071
00072
00073 void image_to_window_coordinates(float, float, float &,float &) const;
00074
00075
00076 bool image_viewport(float& bottom_left_x, float& bottom_left_y,
00077 float& top_right_x, float& top_right_y);
00078
00079
00080
00081
00082 bool compute_as_2d_affine(int width, int height,
00083 float* offsetX, float* offsetY,
00084 float* scaleX, float* scaleY);
00085
00086
00087
00088 void window_to_image_coordinates(int wx, int wy, float *ix,float *iy) const
00089 { window_to_image_coordinates(wx, wy, *ix, *iy); }
00090
00091
00092
00093 void image_to_window_coordinates(float ix,float iy,float *wx,float *wy) const
00094 { image_to_window_coordinates(ix, iy, *wx, *wy); }
00095
00096
00097
00098 bool back_project(double const x[3], double const p[4], double X[4]) const;
00099
00100
00101
00102 vnl_vector<double> back_project(double x,double y, vnl_double_4 const &p) const;
00103
00104
00105
00106 vnl_vector<double> back_project(double x,double y,double z,vnl_double_4 const &p) const;
00107
00108
00109
00110 vnl_vector<double> back_project(vnl_double_2 const &x,vnl_double_4 const &p) const;
00111
00112
00113
00114 vnl_vector<double> back_project(vnl_double_3 const &x,vnl_double_4 const &p) const;
00115
00116 private:
00117 int vp[4];
00118 vnl_double_4x4 P;
00119 vnl_double_4x4 M;
00120 void inspect();
00121 };
00122
00123 #endif // vgui_projection_inspector_h_