20 vnl_double_3
const& point_3d,
24 if (cam->
type_name()==
"vpgl_generic_camera")
31 r = vnl_double_3(dir.
x(), dir.
y(), dir.
z());
36 cam->
project(point_3d[0], point_3d[1], point_3d[2], u,
v);
37 vnl_double_2 image_point(u,
v);
40 vnl_double_4 plane(0, 0, 1.0, -point_3d[2]+ 1.0);
43 vnl_double_3 shifted_point;
49 r = shifted_point - point_3d;
58 vnl_double_3 p3d(point_3d.
x(), point_3d.
y(), point_3d.
z());
61 if (!success)
return false;
62 r.
set(tr[0], tr[1], tr[2]);
75 if (!success)
return false;
89 double origin_z,
double dz,
104 vnl_double_3
const& point_3d,
128 double zmax = z_off + z_scale;
139 const double u,
const double v,
147 double zmax = z_off + z_scale;
157 initial_guess, origin))
166 mid_initial_guess, mid_point))
169 dir = mid_point - origin;
177 const double u,
const double v,
182 if (!success)
return false;
183 ray.set(origin, dir);
197 double zmax = z_off + z_scale;
208 initial_guess, point1))
211 initial_guess, point2))
220 mid_initial_guess, mid_point1))
275 zaxis[0]=0.0; zaxis[1]=0.0; zaxis[2]=1.0;
277 a0 = r0i*zaxis; a1 = r1i*zaxis;
279 return std::acos(dp);
287 zaxis[0]=0.0; zaxis[1]=0.0; zaxis[2]=1.0;
289 a0 = r0i*zaxis; a1 = r1i*zaxis;
296 double ang0 = r0_alpha_rod.
magnitude(), ang1 = r1_alpha_rod.magnitude();
297 return std::fabs(ang0-ang1);
304 v(ray_dir.
x(), ray_dir.
y(), ray_dir.
z());
313 double el_rad = elevation*vnl_math::pi_over_180;
314 double s = std::sin(el_rad), c = std::cos(el_rad);
315 double az_rad = azimuth*vnl_math::pi_over_180;
316 double x = s*std::cos(az_rad), y = s*std::sin(az_rad), z = c;
double vgl_distance(vgl_point_2d< T >const &p1, vgl_point_2d< T >const &p2)
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).
static bool principal_ray(vpgl_proj_camera< double > const &cam, vgl_ray_3d< double > &pray)
vgl_rotation_3d< T > inverse() const
vnl_vector_fixed< T, 3 > as_rodrigues() const
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...
vgl_point_3d< T > vgl_intersection(const std::vector< vgl_plane_3d< T > > &p)
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.
virtual vgl_homg_point_3d< T > camera_center() const
Find the 3d coordinates of the center of the camera.
vgl_homg_point_3d< T > camera_center() const override
Return the known camera center instead of computing it in the base class.
virtual std::string type_name() const
class identity functions for casting.
This class implements the perspective camera class as described in Hartley & Zisserman as a finite ca...
bool is_behind_camera(const vgl_homg_point_3d< T > &world_point) const
Determine whether the given point lies in front of the principal plane.
T scale(const coor_index coor_index) const
get a specific scale value.
const vnl_matrix_fixed< T, 3, 4 > & get_matrix() const
Return a copy of the camera matrix.
vgl_ray_3d< T > ray(const T u, const T v) const
the ray corresponding to a given pixel.
virtual void project(const T x, const T y, const T z, T &u, T &v) const =0
The generic camera interface. u represents image column, v image row.
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.
void set(T vx, T vy, T vz)
T dot_product(v const &a, v const &b)
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.
T offset(const coor_index coor_index) const
get a specific offset value.
static bool bproj_plane(const vpgl_camera< double > *cam, vnl_double_2 const &image_point, vnl_double_4 const &plane, vnl_double_3 const &initial_guess, vnl_double_3 &world_point, double error_tol=0.05, double relative_diameter=1.0)
Generic camera interfaces (pointer for abstract class).
Methods for computing the camera ray direction at a given 3-d point and other operations on camera ra...
Methods for back_projecting from cameras to 3-d geometric structures.