JWS C++ Library
C++ language utility library
jwscxx::graphics::Stereo_camera_d Class Reference

Stereo pair of cameras for 3D viewing in OpenGL. More...

#include <camera.h>

Inheritance diagram for jwscxx::graphics::Stereo_camera_d:
Collaboration diagram for jwscxx::graphics::Stereo_camera_d:

List of all members.

Public Member Functions

 Stereo_camera_d (double focal_pt_x, double focal_pt_y, double focal_pt_z, double ref_pt_x, double ref_pt_y, double ref_pt_z, double up_x, double up_y, double up_z, double aperture, double clip_near, double clip_far) throw (jwscxx::base::Arg_error)
 Constructs a Stereo_camera_d.
 Stereo_camera_d (const jwsc::Vector_d *focal_pt, const jwsc::Vector_d *ref_pt, const jwsc::Vector_d *up, double aperture, double clip_near, double clip_far) throw (jwscxx::base::Arg_error)
 Constructs a Stereo_camera_d.
 Stereo_camera_d (const Stereo_camera_d &c)
 Constructs a camera by copying another.
 Stereo_camera_d (const char *fname) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error)
 Reads a camera from an input file.
 Stereo_camera_d (std::istream &in) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error)
 Reads a camera from an input stream.
virtual ~Stereo_camera_d ()
 Deletes this Camera_d.
virtual Stereo_camera_doperator= (const Stereo_camera_d &c)
 Copies a camera into this one.
virtual Stereo_camera_dclone () const
 Clones this camera.
const jwsc::Vector_d * get_left_prp () const
 Returns a constant pointer to the left camera focal point.
const jwsc::Vector_d * get_right_prp () const
 Returns a constant pointer to the right camera focal point.
const jwsc::Vector_d * get_left_vrp () const
 Returns a constant pointer to the left camera reference point.
const jwsc::Vector_d * get_right_vrp () const
 Returns a constant pointer to the right camera reference point.
void set_aperture (double aperture) throw (jwscxx::base::Arg_error)
 Sets the vertical aperture.
void set_f_with_new_aperture_using_prp (double f) throw (jwscxx::base::Arg_error)
 Sets the focal length and updates the aperture by changing the left and right prp.
void set_f_with_same_aperture_using_prp (double f) throw (jwscxx::base::Arg_error)
 Sets the focal length using the same aperture by changing the left and right prp.
void set_f_with_new_aperture_using_vrp (double f) throw (jwscxx::base::Arg_error)
 Sets the focal length and updates the aperture by changing the vrp.
void set_f_with_same_aperture_using_vrp (double f) throw (jwscxx::base::Arg_error)
 Sets the focal length using the same aperture by changing the vrp.
void set_clipping (double clip_near, double clip_far) throw (jwscxx::base::Arg_error)
 Sets the clipping planes.
void rotate (double angle, double x, double y, double z) throw (jwscxx::base::Arg_error)
 Rotates this Stereo_camera_d around a vector.
void rotate (double angle, const jwsc::Vector_d *r) throw (jwscxx::base::Arg_error)
 Rotates this Stereo_camera_d around a vector.
void translate (double x, double y, double z)
 Translates this Stereo_camera_d.
void translate (const jwsc::Vector_d *t) throw (jwscxx::base::Arg_error)
 Translates this Stereo_camera_d.
void look_at (double focal_pt_x, double focal_pt_y, double focal_pt_z, double ref_pt_x, double ref_pt_y, double ref_pt_z, double up_x, double up_y, double up_z) throw (jwscxx::base::Arg_error)
 Sets the position, direction and focal length of the camera.
void set_left_gl_modelview ()
 Sets the left GL model view matrix.
void set_right_gl_modelview ()
 Sets the right GL model view matrix.
void set_left_gl_projection ()
 Sets the left GL projection matrix.
void set_right_gl_projection ()
 Sets the right GL projection matrix.
void read (std::istream &in) throw (jwscxx::base::IO_error, jwscxx::base::Arg_error)
 Reads this stereo camera from an input stream.
void write (std::ostream &out) const throw (jwscxx::base::IO_error)
 Writes this stereo camera to an output stream.

Protected Attributes

jwsc::Vector_d * left_vrp
 Left view reference point.
jwsc::Vector_d * right_vrp
 Right view reference point.
jwsc::Vector_d * left_prp
 Left projection reference point.
jwsc::Vector_d * right_prp
 Right projection reference point.
double separation
 Seperation between the stereo cameras.
double ndfl
 Distance to the near clipping plane divided by the focal length.

Detailed Description

Stereo pair of cameras for 3D viewing in OpenGL.

Uses single precision, floating point values.

Definition at line 1065 of file camera.h.


Constructor & Destructor Documentation

Stereo_camera_d::Stereo_camera_d ( double  focal_pt_x,
double  focal_pt_y,
double  focal_pt_z,
double  ref_pt_x,
double  ref_pt_y,
double  ref_pt_z,
double  up_x,
double  up_y,
double  up_z,
double  aperture,
double  clip_near,
double  clip_far 
) throw (jwscxx::base::Arg_error)

Constructs a Stereo_camera_d.

Parameters:
focal_pt_xX-coord of the focal point.
focal_pt_yY-coord of the focal point.
focal_pt_zZ-coord of the focal point.
ref_pt_xX-coord of the reference point.
ref_pt_yY-coord of the reference point.
ref_pt_zZ-coord of the reference point.
up_xX-coord of the up vector.
up_yY-coord of the up vector.
up_zZ-coord of the up vector.
apertureAngle, in degrees, of the vertical field of view.
clip_nearNear clipping plane for the GL frustum. Must be >= 0.
clip_farFar clipping plane for the GL frustum. Must be >= 0.
Note:
The view seperation is calculated as
Exceptions:
jwscxx::base::Arg_errorInvalid up vector, aperture, or clipping planes.

Definition at line 3519 of file camera.cpp.

Stereo_camera_d::Stereo_camera_d ( const jwsc::Vector_d *  focal_pt,
const jwsc::Vector_d *  ref_pt,
const jwsc::Vector_d *  up,
double  aperture,
double  clip_near,
double  clip_far 
) throw (jwscxx::base::Arg_error)

Constructs a Stereo_camera_d.

Parameters:
focal_ptFocal point.
ref_ptReference point.
upUp vector.
apertureAngle, in degrees, of the vertical field of view.
clip_nearNear clipping plane for the GL frustum. Must be >= 0.
clip_farFar clipping plane for the GL frustum. Must be >= 0.
Note:
The view seperation is calculated as
Exceptions:
jwscxx::base::Arg_errorInvalid up vector, aperture, or clipping planes.

Definition at line 3563 of file camera.cpp.

Stereo_camera_d::Stereo_camera_d ( const Stereo_camera_d c)

Constructs a camera by copying another.

Parameters:
cCamera to copy into this one.

Definition at line 3584 of file camera.cpp.

Stereo_camera_d::Stereo_camera_d ( const char *  fname) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error)

Reads a camera from an input file.

The file format is expected to be in ASCII as follows

        Type: type_info name
         VRP: x y z
         PRP: x y z
           U: x y z
           V: x y z
           N: x y z
           F: focal_length
    Aperture: aperture   
        Near: near
         Far: far
    Left VRP: x y z
   Right VRP: x y z
    Left PRP: x y z
   Right PRP: x y z
Parameters:
fnameInput file to read this camera from.
Exceptions:
jwscxx::base::IO_errorCould not read from in.
jwscxx::base::Arg_errorInvalid arguments in file to read from.

Definition at line 3621 of file camera.cpp.

Stereo_camera_d::Stereo_camera_d ( std::istream &  in) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error)

Reads a camera from an input stream.

The file format is expected to be in ASCII as follows

        Type: type_info name
         VRP: x y z
         PRP: x y z
           U: x y z
           V: x y z
           N: x y z
           F: focal_length
    Aperture: aperture   
        Near: near
         Far: far
    Left VRP: x y z
   Right VRP: x y z
    Left PRP: x y z
   Right PRP: x y z
Parameters:
inInput stream to read this camera from.
Exceptions:
jwscxx::base::IO_errorCould not read from in.
jwscxx::base::Arg_errorInvalid arguments in file to read from.

Definition at line 3659 of file camera.cpp.

Stereo_camera_d::~Stereo_camera_d ( ) [virtual]

Deletes this Camera_d.

Definition at line 3672 of file camera.cpp.


Member Function Documentation

Stereo_camera_d & Stereo_camera_d::operator= ( const Stereo_camera_d c) [virtual]

Copies a camera into this one.

Performs a deep copy of this camera.

Parameters:
cCamera to copy into this one.
Returns:
A reference to this camera.

Definition at line 3688 of file camera.cpp.

Stereo_camera_d * Stereo_camera_d::clone ( ) const [virtual]

Clones this camera.

Returns:
A new copy of this camera.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3705 of file camera.cpp.

const jwsc::Vector_d * Stereo_camera_d::get_left_prp ( ) const

Returns a constant pointer to the left camera focal point.

Definition at line 3711 of file camera.cpp.

const jwsc::Vector_d * Stereo_camera_d::get_right_prp ( ) const

Returns a constant pointer to the right camera focal point.

Definition at line 3717 of file camera.cpp.

const jwsc::Vector_d * Stereo_camera_d::get_left_vrp ( ) const

Returns a constant pointer to the left camera reference point.

Definition at line 3723 of file camera.cpp.

const jwsc::Vector_d * Stereo_camera_d::get_right_vrp ( ) const

Returns a constant pointer to the right camera reference point.

Definition at line 3729 of file camera.cpp.

void Stereo_camera_d::set_aperture ( double  aperture) throw (jwscxx::base::Arg_error) [virtual]

Sets the vertical aperture.

Parameters:
apertureNew vertical aperture, in degrees.
Exceptions:
jwscxx::base::Arg_errorAngle must be >= 0.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3740 of file camera.cpp.

void Stereo_camera_d::set_f_with_new_aperture_using_prp ( double  f) throw (jwscxx::base::Arg_error) [virtual]

Sets the focal length and updates the aperture by changing the left and right prp.

In order to keep the size of the view the same, computes a new aperture from the new focal length.

Parameters:
fNew focal length.
Exceptions:
jwscxx::base::Arg_errorInvalid focal length.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3756 of file camera.cpp.

void Stereo_camera_d::set_f_with_same_aperture_using_prp ( double  f) throw (jwscxx::base::Arg_error) [virtual]

Sets the focal length using the same aperture by changing the left and right prp.

The aperture is not changed, instead the size of the image plane is changed.

Parameters:
fNew focal length.
Exceptions:
jwscxx::base::Arg_errorInvalid focal length.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3792 of file camera.cpp.

void Stereo_camera_d::set_f_with_new_aperture_using_vrp ( double  f) throw (jwscxx::base::Arg_error) [virtual]

Sets the focal length and updates the aperture by changing the vrp.

The aperture is updated to make the image plane the same size with the new focal length.

Parameters:
fNew focal length.
Exceptions:
jwscxx::base::Arg_errorInvalid focal length.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3828 of file camera.cpp.

void Stereo_camera_d::set_f_with_same_aperture_using_vrp ( double  f) throw (jwscxx::base::Arg_error) [virtual]

Sets the focal length using the same aperture by changing the vrp.

The aperture is not changed, instead the size of the image plane is changed.

Parameters:
fNew focal length.
Exceptions:
jwscxx::base::Arg_errorInvalid focal length.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3864 of file camera.cpp.

void Stereo_camera_d::set_clipping ( double  clip_near,
double  clip_far 
) throw (jwscxx::base::Arg_error) [virtual]

Sets the clipping planes.

Parameters:
clip_nearNear clipping plane for the GL frustum. Must be >= 0.
clip_farFar clipping plane for the GL frustum. Must be >= 0.
Exceptions:
jwscxx::base::Arg_errorInvalid clipping planes.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3898 of file camera.cpp.

void Stereo_camera_d::rotate ( double  phi,
double  x,
double  y,
double  z 
) throw (jwscxx::base::Arg_error) [virtual]

Rotates this Stereo_camera_d around a vector.

Parameters:
phiAngle to rotate, in radians. Use a positive value for clockwise, negative for counter-clockwise.
xX-coord of the vector to rotate around.
yY-coord of the vector to rotate around.
zZ-coord of the vector to rotate around.
Exceptions:
jwscxx::base::Arg_errorInvalid vector to rotate around.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3916 of file camera.cpp.

void Stereo_camera_d::rotate ( double  angle,
const jwsc::Vector_d *  r 
) throw (jwscxx::base::Arg_error) [virtual]

Rotates this Stereo_camera_d around a vector.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3928 of file camera.cpp.

void Stereo_camera_d::translate ( double  x,
double  y,
double  z 
) [virtual]

Translates this Stereo_camera_d.

Parameters:
xX-coord of the vector to translate by.
yY-coord of the vector to translate by.
zZ-coord of the vector to translate by.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3940 of file camera.cpp.

void Stereo_camera_d::translate ( const jwsc::Vector_d *  t) throw (jwscxx::base::Arg_error) [virtual]

Translates this Stereo_camera_d.

Parameters:
tVector to translate by.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3957 of file camera.cpp.

void Stereo_camera_d::look_at ( double  focal_pt_x,
double  focal_pt_y,
double  focal_pt_z,
double  ref_pt_x,
double  ref_pt_y,
double  ref_pt_z,
double  up_x,
double  up_y,
double  up_z 
) throw (jwscxx::base::Arg_error) [virtual]

Sets the position, direction and focal length of the camera.

Parameters:
focal_pt_xX-coord of the focal point.
focal_pt_yY-coord of the focal point.
focal_pt_zZ-coord of the focal point.
ref_pt_xX-coord of the reference point.
ref_pt_yY-coord of the reference point.
ref_pt_zZ-coord of the reference point.
up_xX-coord of the up vector.
up_yY-coord of the up vector.
up_zZ-coord of the up vector.
Exceptions:
jwscxx::base::Arg_errorInvalid arguments.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 3983 of file camera.cpp.

void Stereo_camera_d::set_left_gl_modelview ( )

Sets the left GL model view matrix.

Switches the GL matrix mode to GL_MODELVIEW, loads the identity matrix, and multiplies the camera rotation and translation matrices.

Definition at line 4026 of file camera.cpp.

void Stereo_camera_d::set_right_gl_modelview ( )

Sets the right GL model view matrix.

Switches the GL matrix mode to GL_MODELVIEW, loads the identity matrix, and multiplies the camera rotation and translation matrices.

Definition at line 4048 of file camera.cpp.

void Stereo_camera_d::set_left_gl_projection ( )

Sets the left GL projection matrix.

Switches the GL matrix mode to GL_PROJECTION, loads the identity matrix, and sets the perspective frustum.

Definition at line 4070 of file camera.cpp.

void Stereo_camera_d::set_right_gl_projection ( )

Sets the right GL projection matrix.

Switches the GL matrix mode to GL_PROJECTION, loads the identity matrix, and sets the perspective frustum.

Definition at line 4090 of file camera.cpp.

void Stereo_camera_d::read ( std::istream &  in) throw (jwscxx::base::IO_error, jwscxx::base::Arg_error) [virtual]

Reads this stereo camera from an input stream.

The file format is expected to be in ASCII as follows

        Type: type_info name
         VRP: x y z
         PRP: x y z
           U: x y z
           V: x y z
           N: x y z
           F: focal_length
    Aperture: aperture   
        Near: near
         Far: far
    Left VRP: x y z
   Right VRP: x y z
    Left PRP: x y z
   Right PRP: x y z
Parameters:
inInput stream to read this camera from.
Exceptions:
jwscxx::base::IO_errorCould not read from in.
jwscxx::base::Arg_errorInvalid arguments in file to read from.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 4131 of file camera.cpp.

void Stereo_camera_d::write ( std::ostream &  out) const throw (jwscxx::base::IO_error) [virtual]

Writes this stereo camera to an output stream.

The file format is in ASCII as follows

        Type: type_info name
         VRP: x y z
         PRP: x y z
           U: x y z
           V: x y z
           N: x y z
           F: focal_length
    Aperture: aperture   
        Near: near
         Far: far
    Left VRP: x y z
   Right VRP: x y z
    Left PRP: x y z
   Right PRP: x y z
Parameters:
outOutput stream to write this camera to.
Exceptions:
jwscxx::base::IO_errorCould not write to out.

Reimplemented from jwscxx::graphics::Camera_d.

Definition at line 4228 of file camera.cpp.


Member Data Documentation

jwsc::Vector_d* jwscxx::graphics::Stereo_camera_d::left_vrp [protected]

Left view reference point.

Definition at line 1257 of file camera.h.

jwsc::Vector_d* jwscxx::graphics::Stereo_camera_d::right_vrp [protected]

Right view reference point.

Definition at line 1260 of file camera.h.

jwsc::Vector_d* jwscxx::graphics::Stereo_camera_d::left_prp [protected]

Left projection reference point.

Definition at line 1263 of file camera.h.

jwsc::Vector_d* jwscxx::graphics::Stereo_camera_d::right_prp [protected]

Right projection reference point.

Definition at line 1266 of file camera.h.

Seperation between the stereo cameras.

Definition at line 1269 of file camera.h.

Distance to the near clipping plane divided by the focal length.

Definition at line 1275 of file camera.h.


The documentation for this class was generated from the following files: