Toast++  1.0.2 (r.539)
Forward and inverse modelling in optical tomography
camera.h
1 #ifndef CAMERA_H
2 #define CAMERA_H
3 
4 #include "mathlib.h"
5 
6 class STOASTLIB Camera
7 {
8  public:
9  Camera()
10  {
11  pixelSize = 1.0;
12  }
13  Camera( int w_, int h_,
14  const RVector & pos_,
15  const RVector & x_, const RVector & y_, const RVector & z_,
16  double pixSize = 1.0)
17  : w(w_), h(h_), pos(pos_), x(x_), y(y_), z(z_), pixelSize(pixSize)
18  {
19  }
20  void init(int w_, int h_, double f_,
21  const RVector & pos_,
22  const RVector & x_, const RVector & y_, const RVector & z_)
23  {
24  w=w_; h=h_;
25  pos=pos_; x=x_; y=y_; z=z_;
26  }
27  virtual void getRayVector(const double ix, const double iy, RVector & rayStart, RVector & rayDir) const = 0;
28  virtual void getPixelCoords(const RVector & p, double & ix, double & iy) const = 0;
29  RVector getPos() const {return pos;}
30  RVector getUp() const {return y;}
31  RVector getViewDir() const {return z;}
32  int getImageWidth() const {return w;}
33  int getImageHeight() const {return h;}
34  double getAspect() const;
35  virtual double getFoVy() const { return 0; }
36  double getPixelSize() {return pixelSize;}
37 
38  protected:
39  int w, h;
40  RVector pos, x, y, z;
41  double pixelSize;
42 };
43 
44 class STOASTLIB PinholeCamera : public Camera
45 {
46  public:
47  PinholeCamera(){}
48  PinholeCamera( int w_, int h_, double f_,
49  const RVector & pos_,
50  const RVector & x_, const RVector & y_,
51  const RVector & z_,
52  double pixSize = 1.0)
53  : Camera(w_, h_, pos_, x_, y_, z_, pixSize), f(f_)
54  {
55  }
56  void getRayVector(const double ix, const double iy, RVector & rayStart, RVector & rayDir) const;
57  void getPixelCoords(const RVector & p, double & ix, double & iy) const;
58  double getFoVy() const;
59 
60  protected:
61  double f;
62 };
63 
64 class STOASTLIB OrthoCamera : public Camera
65 {
66  public:
67  OrthoCamera(){}
68  OrthoCamera(int w_, int h_, double pixSize,
69  const RVector & pos_,
70  const RVector & x_, const RVector & y_, const RVector & z_)
71  : Camera(w_, h_, pos_, x_, y_, z_, pixSize)
72  {
73  }
74  void getRayVector(const double ix, const double iy, RVector & rayStart, RVector & rayDir) const;
75  void getPixelCoords(const RVector & p, double & ix, double & iy) const;
76 };
77 
78 #endif
Definition: camera.h:64
Definition: camera.h:44
Definition: camera.h:6