20 static const PN_stdfloat cylindrical_k = 60.0f;
    27 PT(
Lens) CylindricalLens::
    43 bool CylindricalLens::
    44 do_extrude(
const Lens::CData *lens_cdata,
    45            const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point)
 const {
    48   LPoint3 f = point2d * do_get_film_mat_inv(lens_cdata);
    50   PN_stdfloat focal_length = do_get_focal_length(lens_cdata);
    51   PN_stdfloat angle = f[0] * cylindrical_k / focal_length;
    52   PN_stdfloat sinAngle, cosAngle;
    53   csincos(deg_2_rad(angle), &sinAngle, &cosAngle);
    57   LPoint3 v(sinAngle, cosAngle, f[1] / focal_length);
    61   const LMatrix4 &lens_mat = do_get_lens_mat(lens_cdata);
    62   const LMatrix4 &proj_inv_mat = do_get_projection_mat_inv(lens_cdata);
    64   near_point = (v * do_get_near(lens_cdata)) * proj_inv_mat * lens_mat;
    65   far_point = (v * do_get_far(lens_cdata)) * proj_inv_mat * lens_mat;
    83 bool CylindricalLens::
    84 do_extrude_vec(
const Lens::CData *lens_cdata, 
const LPoint3 &point2d, LVector3 &vec)
 const {
    87   LPoint3 f = point2d * do_get_film_mat_inv(lens_cdata);
    89   PN_stdfloat focal_length = do_get_focal_length(lens_cdata);
    90   PN_stdfloat angle = f[0] * cylindrical_k / focal_length;
    91   PN_stdfloat sinAngle, cosAngle;
    92   csincos(deg_2_rad(angle), &sinAngle, &cosAngle);
    94   vec = LVector3(sinAngle, cosAngle, 0.0f) * do_get_projection_mat_inv(lens_cdata) * do_get_lens_mat(lens_cdata);
   111 bool CylindricalLens::
   112 do_project(
const Lens::CData *lens_cdata, 
const LPoint3 &point3d, LPoint3 &point2d)
 const {
   114   LPoint3 p = point3d * do_get_lens_mat_inv(lens_cdata) * do_get_projection_mat(lens_cdata);
   119   LVector2 xy(p[0], p[1]);
   122   PN_stdfloat pdist = xy.length();
   124     point2d.set(0.0f, 0.0f, 0.0f);
   128   PN_stdfloat focal_length = do_get_focal_length(lens_cdata);
   131   PN_stdfloat z = (pdist - do_get_near(lens_cdata)) / (do_get_far(lens_cdata) - do_get_near(lens_cdata));
   136      rad_2_deg(catan2(xy[0], xy[1])) * focal_length / cylindrical_k,
   138      p[2] * focal_length / pdist,
   144   point2d = point2d * do_get_film_mat(lens_cdata);
   147     point2d[0] >= -1.0f && point2d[0] <= 1.0f &&
   148     point2d[1] >= -1.0f && point2d[1] <= 1.0f;
   157 PN_stdfloat CylindricalLens::
   158 fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, 
bool horiz)
 const {
   160     return focal_length * fov / cylindrical_k;
   162     return (ctan(deg_2_rad(fov * 0.5f)) * focal_length) * 2.0f;
   172 PN_stdfloat CylindricalLens::
   173 fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, 
bool horiz)
 const {
   175     return film_size * cylindrical_k / fov;
   177     return film_size * 0.5f / ctan(deg_2_rad(fov * 0.5f));
   187 PN_stdfloat CylindricalLens::
   188 film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, 
bool horiz)
 const {
   190     return film_size * cylindrical_k / focal_length;
   192     return rad_2_deg(catan(film_size * 0.5f / focal_length)) * 2.0f;
 A base class for any number of different kinds of lenses, linear and otherwise.
 
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
 
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
 
TypeHandle is the identifier used to differentiate C++ class types.