vpgl_ray.h
Go to the documentation of this file.
1 // This is core/vpgl/algo/vpgl_ray.h
2 #ifndef vpgl_ray_h_
3 #define vpgl_ray_h_
4 //:
5 // \file
6 // \brief Methods for computing the camera ray direction at a given 3-d point and other operations on camera rays
7 // \author J. L. Mundy
8 // \date Dec 22, 2007
9 
15 #include <vnl/vnl_double_3.h>
16 #include <vgl/vgl_point_3d.h>
17 #include <vgl/vgl_vector_3d.h>
18 #include <vgl/vgl_ray_3d.h>
19 
20 class vpgl_ray
21 {
22  public:
23  //: Generic camera interfaces (pointer for abstract class)
24  // Solves using back-project so will work for any camera
25  // The ray direction assumes the camera is in the positive half-space
26  // of the x-y plane. This assumption is necessary since some cameras
27  // don't have a natural center of projection (e.g. rational cameras).
28 
29  // === vnl interface ===
30 
31  //: compute the ray at a given 3-d point
32  static bool ray(const vpgl_camera<double>* cam,
33  vnl_double_3 const& point_3d,
34  vnl_double_3& ray);
35 
36  // === vgl interface ===
37 
38  //: compute the ray at a given 3-d point
39  static bool ray(const vpgl_camera<double>* cam,
40  vgl_point_3d<double> const& point_3d,
42 
43  //: vgl interface, origin_z defines an x-y plane wherein lies the ray origin
44  static bool ray(const vpgl_camera<double>* cam,
45  vgl_point_3d<double> const& point_3d,
46  double origin_z,
48 
49  //: vgl interface, origin_z defines an x-y plane wherein lies the ray origin
50  // and dz defines a plane to compute a second intersection point for the ray direction
51  // the inital guess is for the x and y values where the ray intersects the z planes
52  static bool ray(const vpgl_camera<double>* cam,
53  vgl_point_2d<double> image_pt,
54  vgl_point_2d<double> const& inital_guess,
55  double origin_z, double dz,
57 
58  // +++ concrete rational camera interfaces +++
59 
60  // === vnl interface ===
61 
62  //: compute the ray at a given 3-d point
63  static bool ray(vpgl_rational_camera<double> const& rcam,
64  vnl_double_3 const& point_3d,
65  vnl_double_3& ray);
66 
67  // === vgl interface ===
68 
69  //: compute the ray at a given 3-d point
70  static bool ray(vpgl_rational_camera<double> const& rcam,
71  vgl_point_3d<double> const& point_3d,
73 
74  //: compute the ray at a given 3-d point
75  static bool ray(vpgl_rational_camera<double> const& rcam,
76  vgl_point_3d<double> const& point_3d,
78 
79  //: compute a ray in local Cartesian coordinates at a given (u, v)
80  static bool ray(vpgl_local_rational_camera<double> const& lrcam,
81  const double u, const double v,
83 
84  //: compute a ray in local Cartesian coordinates at a given (u, v)
85  static bool ray(vpgl_local_rational_camera<double> const& lrcam,
86  const double u, const double v,
88 
89  //: compute a ray in local Cartesian coordinates for a local rational cam
90  static bool plane_ray(vpgl_local_rational_camera<double> const& lrcam,
91  const vgl_point_2d<double> image_point1,
92  const vgl_point_2d<double> image_point2,
93  vgl_plane_3d<double>& plane);
94  // ====== projective camera =====
95  static bool ray(vpgl_proj_camera<double> const& cam,
96  vgl_point_3d<double> const& world_pt,
98 
99  static bool principal_ray(vpgl_proj_camera<double> const& cam,
100  vgl_ray_3d<double>& pray);
101 
102  // ====== perspective camera =====
103  static bool ray(vpgl_perspective_camera<double> const& cam,
104  vgl_point_3d<double> const& world_pt,
106 
108  vgl_ray_3d<double>& pray) {
109  vpgl_proj_camera<double> const* procam =
110  static_cast<vpgl_proj_camera<double> const* >(&cam);
111  return vpgl_ray::principal_ray(*procam, pray);
112  }
113 
114  // ====== generic camera =====
115  static bool ray(vpgl_generic_camera<double> const& cam,
116  vgl_point_3d<double> const& world_pt,
118 
119 
120  // ====== operations on rotation matrices with respect to camera rays ======
121 
122  //: angle(radians) between principal ray of one rotation and the principal ray of a second rotation
123  // Rotations \p r0 and \p r1 are expressed as vgl_rotation<T>
124  static double angle_between_rays(vgl_rotation_3d<double> const& r0, vgl_rotation_3d<double> const& r1);
125 
126  //: the rotation about the principal ray required to go from \p r0 to \p r1
127  static double rot_about_ray(vgl_rotation_3d<double> const& r0, vgl_rotation_3d<double> const& r1);
128 
129  //: the rotation required to point the principal ray in a given direction, starting with the identity camera (principal ray in z direction)
131  //: define the principal ray in spherical coordinates (in degrees, azimuth [0 360], elevation [0, 180], x axis = (0, 90), y axis = (90, 90, z axis = (0, 0)).
132  static vgl_rotation_3d<double> rot_to_point_ray(double azimuth, double elevation);
133  private:
134  //: constructor/destructor private - static methods only
135  vpgl_ray() = delete;
136  ~vpgl_ray() = delete;
137 };
138 
139 #endif // vpgl_ray_h_
A class for the perspective camera model.
static bool ray(const vpgl_camera< double > *cam, vnl_double_3 const &point_3d, vnl_double_3 &ray)
Generic camera interfaces (pointer for abstract class).
Definition: vpgl_ray.cxx:19
~vpgl_ray()=delete
static bool principal_ray(vpgl_proj_camera< double > const &cam, vgl_ray_3d< double > &pray)
Definition: vpgl_ray.cxx:239
A camera model based on ratios of cubic polynomials.
static vgl_rotation_3d< double > rot_to_point_ray(vgl_vector_3d< double > const &ray_dir)
the rotation required to point the principal ray in a given direction, starting with the identity cam...
Definition: vpgl_ray.cxx:301
#define v
static bool plane_ray(vpgl_local_rational_camera< double > const &lrcam, const vgl_point_2d< double > image_point1, const vgl_point_2d< double > image_point2, vgl_plane_3d< double > &plane)
compute a ray in local Cartesian coordinates for a local rational cam.
Definition: vpgl_ray.cxx:188
vpgl_ray()=delete
constructor/destructor private - static methods only.
This class implements the perspective camera class as described in Hartley & Zisserman as a finite ca...
A local rational camera model.
static double rot_about_ray(vgl_rotation_3d< double > const &r0, vgl_rotation_3d< double > const &r1)
the rotation about the principal ray required to go from r0 to r1.
Definition: vpgl_ray.cxx:282
The generic camera.
static bool principal_ray(vpgl_perspective_camera< double > const &cam, vgl_ray_3d< double > &pray)
Definition: vpgl_ray.h:107
static double angle_between_rays(vgl_rotation_3d< double > const &r0, vgl_rotation_3d< double > const &r1)
angle(radians) between principal ray of one rotation and the principal ray of a second rotation.
Definition: vpgl_ray.cxx:271