Gan_Vector3 v3X, v3x; /* declare camera/scene points X, x */ Gan_Vector3 v3L, v3l; /* declare camera/scene lines L, l */ /* fill camera point X & line L with values */ gan_vec3_fill_q ( &v3X, 1.5, -0.8, 1.2 ); gan_vec3_fill_q ( &v3L, 2.7, 3.9, 3.6 ); /* project point from camera 3D coordinates onto the image X --> x */ gan_camera_project_point_q ( &CameraD, &v3X, &v3x ); /* project line from camera 3D coordinates onto the image L --> l */ gan_camera_project_line_q ( &CameraD, &v3L, &v3l );The point projection function implements the projection equations 5.1 and 5.2. The lines are represented in homogeneous 2D coordinates, so that the line in camera coordinates actually describes a plane in 3D space intersecting the origin (optical centre). If is a point in camera space, the line in the homogeneous 2D space of camera ``rays'' is defined by the equation
There are also versions of the above routines which perform the projection in-place in the input vector. So for instance
Gan_Vector3 v3Xx; /* declare point */ Gan_Vector3 v3Ll; /* declare line */ /* fill camera point X & line L with values */ gan_vec3_fill_q ( &v3Xx, 1.5, -0.8, 1.2 ); gan_vec3_fill_q ( &v3Ll, 2.7, 3.9, 3.6 ); /* project point from camera 3D coordinates onto the image in-place */ gan_camera_project_point_i ( &CameraD, &v3Xx ); /* project line from camera 3D coordinates onto the image in-place */ gan_camera_project_line_i ( &CameraD, &v3Ll );
Back-projection from image to camera coordinates operates similarly. To back-project a point and a line you can use
Gan_Vector3 v3X, v3x; /* declare camera/scene points X, x */ Gan_Vector3 v3L, v3l; /* declare camera/scene lines L, l */ /* fill image point x & line l with values */ gan_vec3_fill_q ( &v3x, 1.5, -0.8, 1.2 ); gan_vec3_fill_q ( &v3l, 2.7, 3.9, 3.6 ); /* back-project point from the image into camera 3D coordinates x --> X */ gan_camera_backproject_point_q ( &CameraD, &v3x, &v3X ); /* OR */ gan_camera_backproject_point_i ( &CameraD, &v3x ); /* in-place */ /* backproject line from the image into camera 3D coordinates l --> L */ gan_camera_backproject_line_q ( &CameraD, &v3l, &v3L ); /* OR */ gan_camera_backproject_line_i ( &CameraD, &v3l ); /* in-place */
The single precision versions of these functions operate similarly. The single precision camera to image projection functions are
Gan_Vector3_f v3X, v3x; /* declare camera/scene points X, x */ Gan_Vector3_f v3L, v3l; /* declare camera/scene lines L, l */ /* fill camera point X & line L with values */ gan_vec3f_fill_q ( &v3X, 1.5F, -0.8F, 1.2F ); gan_vec3f_fill_q ( &v3L, 2.7F, 3.9F, 3.6F ); /* project point from camera 3D coordinates onto the image X --> x */ gan_cameraf_project_point_q ( &CameraF, &v3X, &v3x ); /* OR */ gan_cameraf_project_point_i ( &CameraF, &v3X ); /* in-place */ /* project line from camera 3D coordinates onto the image L --> l */ gan_cameraf_project_line_q ( &CameraF, &v3L, &v3l ); /* OR */ gan_cameraf_project_line_i ( &CameraF, &v3L ); /* in-place */The single precision image to camera back-projection functions are
Gan_Vector3_f v3X, v3x; /* declare camera/scene points X, x */ Gan_Vector3_f v3L, v3l; /* declare camera/scene lines L, l */ /* fill image point x & line l with values */ gan_vec3f_fill_q ( &v3x, 1.5F, -0.8F, 1.2F ); gan_vec3f_fill_q ( &v3l, 2.7F, 3.9F, 3.6F ); /* project point from camera 3D coordinates onto the image X --> x */ gan_cameraf_backproject_point_q ( &CameraF, &v3x, &v3X ); /* OR */ gan_cameraf_backproject_point_i ( &CameraF, &v3x ); /* in-place */ /* project line from camera 3D coordinates onto the image L --> l */ gan_cameraf_backproject_line_q ( &CameraF, &v3l, &v3L ); /* OR */ gan_cameraf_backproject_line_i ( &CameraF, &v3l ); /* in-place */