Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions

CylindricalLens Class Reference

A cylindrical lens. More...

#include "cylindricalLens.h"

Inheritance diagram for CylindricalLens:
Lens TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

List of all members.

Public Member Functions

 CylindricalLens (const CylindricalLens &copy)
virtual TypeHandle force_init_type ()
virtual TypeHandle get_type () const
void operator= (const CylindricalLens &copy)
virtual PT (Lens) make_copy() const

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Protected Member Functions

virtual bool extrude_impl (const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) const
 Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the corresponding vector in space that maps to this point, if such a vector can be determined.
virtual bool extrude_vec_impl (const LPoint3f &point2d, LVector3f &vec) const
 Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the vector that corresponds to the view direction.
virtual float film_to_fov (float film_size, float focal_length, bool horiz) const
 Given a width (or height) on the film and a focal length, compute the field of view in degrees.
virtual float fov_to_film (float fov, float focal_length, bool horiz) const
 Given a field of view in degrees and a focal length, compute the correspdonding width (or height) on the film.
virtual float fov_to_focal_length (float fov, float film_size, bool horiz) const
 Given a field of view in degrees and a width (or height) on the film, compute the focal length of the lens.
virtual bool project_impl (const LPoint3f &point3d, LPoint3f &point2d) const
 Given a 3-d point in space, determine the 2-d point this maps to, in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner.

Detailed Description

A cylindrical lens.

This is the kind of lens generally used for extremely wide panoramic shots. It behaves like a normal perspective lens in the vertical direction, but it is non-linear in the horizontal dimension: a point on the film corresponds to a point in space in linear proportion to its angle to the camera, not to its straight-line distance from the center.

This allows up to 360 degree lenses in the horizontal dimension, with relatively little distortion. The distortion is not very apparent between two relatively nearby points on the film, but it becomes increasingly evident as you compare points widely spaced on the film.

Definition at line 40 of file cylindricalLens.h.


Member Function Documentation

bool CylindricalLens::extrude_impl ( const LPoint3f point2d,
LPoint3f near_point,
LPoint3f far_point 
) const [protected, virtual]

Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the corresponding vector in space that maps to this point, if such a vector can be determined.

The vector is returned by indicating the points on the near plane and far plane that both map to the indicated 2-d point.

The z coordinate of the 2-d point is ignored.

Returns true if the vector is defined, or false otherwise.

Reimplemented from Lens.

Definition at line 54 of file cylindricalLens.cxx.

References Lens::get_far(), Lens::get_film_mat_inv(), Lens::get_focal_length(), Lens::get_lens_mat(), and Lens::get_near().

bool CylindricalLens::extrude_vec_impl ( const LPoint3f point2d,
LVector3f vec 
) const [protected, virtual]

Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner, compute the vector that corresponds to the view direction.

This will be parallel to the normal on the surface (the far plane) corresponding to the lens shape at this point.

See the comment block on Lens::extrude_vec_impl() for a more in-depth comment on the meaning of this vector.

The z coordinate of the 2-d point is ignored.

Returns true if the vector is defined, or false otherwise.

Reimplemented from Lens.

Definition at line 98 of file cylindricalLens.cxx.

References Lens::get_film_mat_inv(), Lens::get_focal_length(), and Lens::get_lens_mat().

float CylindricalLens::film_to_fov ( float  film_size,
float  focal_length,
bool  horiz 
) const [protected, virtual]

Given a width (or height) on the film and a focal length, compute the field of view in degrees.

If horiz is true, this is in the horizontal direction; otherwise, it is in the vertical direction (some lenses behave differently in each direction).

Reimplemented from Lens.

Definition at line 216 of file cylindricalLens.cxx.

float CylindricalLens::fov_to_film ( float  fov,
float  focal_length,
bool  horiz 
) const [protected, virtual]

Given a field of view in degrees and a focal length, compute the correspdonding width (or height) on the film.

If horiz is true, this is in the horizontal direction; otherwise, it is in the vertical direction (some lenses behave differently in each direction).

Reimplemented from Lens.

Definition at line 180 of file cylindricalLens.cxx.

float CylindricalLens::fov_to_focal_length ( float  fov,
float  film_size,
bool  horiz 
) const [protected, virtual]

Given a field of view in degrees and a width (or height) on the film, compute the focal length of the lens.

If horiz is true, this is in the horizontal direction; otherwise, it is in the vertical direction (some lenses behave differently in each direction).

Reimplemented from Lens.

Definition at line 198 of file cylindricalLens.cxx.

bool CylindricalLens::project_impl ( const LPoint3f point3d,
LPoint3f point2d 
) const [protected, virtual]

Given a 3-d point in space, determine the 2-d point this maps to, in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (-1,-1) is the lower-left corner.

Some lens types also set the z coordinate of the 2-d point to a value in the range (-1, 1), where 1 represents a point on the near plane, and -1 represents a point on the far plane.

Returns true if the 3-d point is in front of the lens and within the viewing frustum (in which case point2d is filled in), or false otherwise.

Reimplemented from Lens.

Definition at line 131 of file cylindricalLens.cxx.

References Lens::get_far(), Lens::get_film_mat(), Lens::get_focal_length(), Lens::get_lens_mat_inv(), Lens::get_near(), and LVecBase2f::length().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations