EMAN::ChaoProjector Class Reference

Fast real space projection using Bi-Linear interpolation. More...

#include <projector.h>

Inheritance diagram for EMAN::ChaoProjector:

Inheritance graph
[legend]
Collaboration diagram for EMAN::ChaoProjector:

Collaboration graph
[legend]

List of all members.

Public Member Functions

EMDataproject3d (EMData *vol) const
 Project an 3D image into a 2D image.
EMDatabackproject3d (EMData *imagestack) const
 Back-project a 2D image into a 3D image.
string get_name () const
 Get the projector's name.
string get_desc () const
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

static ProjectorNEW ()

Private Member Functions

int getnnz (Vec3i volsize, int ri, Vec3i origin, int *nray, int *nnz) const
int cb2sph (float *cube, Vec3i volsize, int ri, Vec3i origin, int nnz0, int *ptrs, int *cord, float *sphere) const
int sph2cb (float *sphere, Vec3i volsize, int nray, int ri, int nnz0, int *ptrs, int *cord, float *cube) const
int fwdpj3 (Vec3i volsize, int nray, int nnz, float *dm, Vec3i origin, int ri, int *ptrs, int *cord, float *x, float *y) const
int bckpj3 (Vec3i volsize, int nray, int nnz, float *dm, Vec3i origin, int ri, int *ptrs, int *cord, float *x, float *y) const
int ifix (float a) const
void setdm (vector< float > anglelist, string const angletype, float *dm) const


Detailed Description

Fast real space projection using Bi-Linear interpolation.

(C. Yang)

Definition at line 365 of file projector.h.


Member Function Documentation

EMData * ChaoProjector::project3d ( EMData image  )  const [virtual]

Project an 3D image into a 2D image.

Returns:
A 2D image from the projection.

Implements EMAN::Projector.

Definition at line 1585 of file projector.cpp.

References anglelist, cb2sph(), cord, cube, dm, EMDeleteArray(), fwdpj3(), EMAN::EMData::get_data(), EMAN::Util::get_min(), EMAN::Transform::get_rotation(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), getnnz(), EMAN::Dict::has_key(), images, LOGERR, nnz, nrays, NullPointerException, EMAN::Projector::params, phi, ptrs, EMAN::EMData::set_attr(), EMAN::EMData::set_complex(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), setdm(), EMAN::Dict::size(), sphere, status, theta, and EMAN::EMData::update().

01586 {
01587 
01588         int nrays, nnz, status, j;
01589         float *dm;
01590         int   *ptrs, *cord;
01591         float *sphere, *images;
01592 
01593         int nxvol = vol->get_xsize();
01594         int nyvol = vol->get_ysize();
01595         int nzvol = vol->get_zsize();
01596         Vec3i volsize(nxvol,nyvol,nzvol);
01597 
01598         int dim = Util::get_min(nxvol,nyvol,nzvol);
01599         if (nzvol == 1) {
01600                 LOGERR("The ChaoProjector needs a volume!");
01601                 return 0;
01602         }
01603         Vec3i origin(0,0,0);
01604         // If a sensible origin isn't passed in, choose the middle of
01605         // the cube.
01606         if (params.has_key("origin_x")) {origin[0] = params["origin_x"];}
01607         else {origin[0] = nxvol/2+1;}
01608         if (params.has_key("origin_y")) {origin[1] = params["origin_y"];}
01609         else {origin[1] = nyvol/2+1;}
01610         if (params.has_key("origin_z")) {origin[2] = params["origin_z"];}
01611         else {origin[2] = nzvol/2+1;}
01612 
01613         int ri;
01614         if (params.has_key("radius")) {ri = params["radius"];}
01615         else {ri = dim/2 - 1;}
01616 
01617         // retrieve the voxel values
01618         float *cube = vol->get_data();
01619 
01620         // count the number of voxels within a sphere centered at icent,
01621         // with radius ri
01622         status = getnnz(volsize, ri, origin, &nrays, &nnz);
01623         // need to check status...
01624 
01625         // convert from cube to sphere
01626         sphere = new float[nnz];
01627         ptrs   = new int[nrays+1];
01628         cord   = new int[3*nrays];
01629         if (sphere == NULL || ptrs == NULL || cord == NULL) {
01630                 fprintf(stderr,"ChaoProjector::project3d, failed to allocate!\n");
01631                 exit(1);
01632         }
01633         for (int i = 0; i<nnz; i++) sphere[i] = 0.0;
01634         for (int i = 0; i<nrays+1; i++) ptrs[i] = 0;
01635         for (int i = 0; i<3*nrays; i++) cord[i] = 0;
01636 
01637         status = cb2sph(cube, volsize, ri, origin, nnz, ptrs, cord, sphere);
01638         // check status
01639 
01640         int nangles = 0;
01641         vector<float> anglelist;
01642         string angletype = "SPIDER";
01643         // Do we have a list of angles?
01644         if (params.has_key("anglelist")) {
01645                 anglelist = params["anglelist"];
01646                 nangles = anglelist.size() / 3;
01647         } else {
01648                 Transform* t3d = params["transform"];
01649                 if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified");
01650                 // This part was modified by David Woolford -
01651                 // Before this the code worked only for SPIDER and EMAN angles,
01652                 // but the framework of the Transform3D allows for a generic implementation
01653                 // as specified here.
01654                 Dict p = t3d->get_rotation("spider");
01655                 if(t3d) {delete t3d; t3d=0;}
01656 
01657                 float phi   = p["phi"];
01658                 float theta = p["theta"];
01659                 float psi   = p["psi"];
01660                 anglelist.push_back(phi);
01661                 anglelist.push_back(theta);
01662                 anglelist.push_back(psi);
01663                 nangles = 1;
01664         }
01665         // End David Woolford modifications
01666 
01667         dm = new float[nangles*9];
01668         setdm(anglelist, angletype, dm);
01669 
01670                 // return images
01671         EMData *ret = new EMData();
01672         ret->set_size(nxvol, nyvol, nangles);
01673         ret->set_complex(false);
01674         ret->set_ri(true);
01675 
01676         images = ret->get_data();
01677 
01678         for (j = 1; j <= nangles; j++) {
01679                 status = fwdpj3(volsize, nrays, nnz   , &dm(1,j), origin, ri,
01680                                                 ptrs   ,  cord, sphere, &images(1,1,j));
01681         // check status?
01682         }
01683 
01684         // deallocate all temporary work space
01685         EMDeleteArray(dm);
01686         EMDeleteArray(ptrs);
01687         EMDeleteArray(cord);
01688         EMDeleteArray(sphere);
01689 
01690         if (!params.has_key("anglelist")) {
01691                 Transform* t3d = params["transform"];
01692                 ret->set_attr("xform.projection",t3d);
01693                 if(t3d) {delete t3d; t3d=0;}
01694         }
01695         ret->update();
01696         return ret;
01697 }

EMData * ChaoProjector::backproject3d ( EMData image  )  const [virtual]

Back-project a 2D image into a 3D image.

Returns:
A 3D image from the backprojection.

Implements EMAN::Projector.

Definition at line 1704 of file projector.cpp.

References anglelist, bckpj3(), cb2sph(), cord, cube, dm, EMDeleteArray(), EMAN::EMData::get_data(), EMAN::Util::get_min(), EMAN::Transform::get_rotation(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), getnnz(), EMAN::Dict::has_key(), images, LOGERR, nnz, nrays, NullPointerException, EMAN::Projector::params, phi, ptrs, EMAN::EMData::set_complex(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), setdm(), EMAN::Dict::size(), sph2cb(), sphere, status, theta, EMAN::EMData::to_zero(), and EMAN::EMData::update().

01705 {
01706         int nrays, nnz, status, j;
01707         float *dm;
01708         int   *ptrs, *cord;
01709         float *sphere, *images, *cube;
01710 
01711         int nximg   = imagestack->get_xsize();
01712         int nyimg   = imagestack->get_ysize();
01713         int nslices = imagestack->get_zsize();
01714 
01715         int dim = Util::get_min(nximg,nyimg);
01716         Vec3i volsize(nximg,nyimg,dim);
01717 
01718         Vec3i origin(0,0,0);
01719         // If a sensible origin isn't passed in, choose the middle of
01720         // the cube.
01721         if (params.has_key("origin_x")) {origin[0] = params["origin_x"];}
01722         else {origin[0] = nximg/2+1;}
01723         if (params.has_key("origin_y")) {origin[1] = params["origin_y"];}
01724         else {origin[1] = nyimg/2+1;}
01725         if (params.has_key("origin_z")) {origin[1] = params["origin_z"];}
01726         else {origin[2] = dim/2+1;}
01727 
01728         int ri;
01729         if (params.has_key("radius")) {ri = params["radius"];}
01730         else {ri = dim/2 - 1;}
01731 
01732         // retrieve the voxel values
01733         images = imagestack->get_data();
01734 
01735         // count the number of voxels within a sphere centered at icent,
01736         // with radius ri
01737         status = getnnz(volsize, ri, origin, &nrays, &nnz);
01738         // need to check status...
01739 
01740         // convert from cube to sphere
01741         sphere = new float[nnz];
01742         ptrs   = new int[nrays+1];
01743         cord   = new int[3*nrays];
01744         if (sphere == NULL || ptrs == NULL || cord == NULL) {
01745                 fprintf(stderr,"ChaoProjector::backproject3d, failed to allocate!\n");
01746                 exit(1);
01747         }
01748         for (int i = 0; i<nnz; i++) sphere[i] = 0.0;
01749         for (int i = 0; i<nrays+1; i++) ptrs[i] = 0;
01750         for (int i = 0; i<3*nrays; i++) cord[i] = 0;
01751 
01752         int nangles = 0;
01753         vector<float> anglelist;
01754         string angletype = "SPIDER";
01755         // Do we have a list of angles?
01756         if (params.has_key("anglelist")) {
01757                 anglelist = params["anglelist"];
01758                 nangles = anglelist.size() / 3;
01759         } else {
01760                 Transform* t3d = params["transform"];
01761                 if ( t3d == NULL ) throw NullPointerException("The transform3d object (required for projection), was not specified");
01762                 // This part was modified by David Woolford -
01763                 // Before this the code worked only for SPIDER and EMAN angles,
01764                 // but the framework of the Transform3D allows for a generic implementation
01765                 // as specified here.
01766                 //  This was broken by david.  we need here a loop over all projections and put all angles on stack  PAP 06/28/09
01767                 Dict p = t3d->get_rotation("spider");
01768                 if(t3d) {delete t3d; t3d=0;}
01769 
01770                 float phi = p["phi"];
01771                 float theta = p["theta"];
01772                 float psi = p["psi"];
01773                 anglelist.push_back(phi);
01774                 anglelist.push_back(theta);
01775                 anglelist.push_back(psi);
01776                 nangles = 1;
01777         }
01778 
01779         // End David Woolford modifications
01780 
01781         if (nslices != nangles) {
01782                 LOGERR("the number of images does not match the number of angles");
01783                 return 0;
01784         }
01785 
01786         dm = new float[nangles*9];
01787         setdm(anglelist, angletype, dm);
01788 
01789         // return volume
01790         EMData *ret = new EMData();
01791         ret->set_size(nximg, nyimg, dim);
01792         ret->set_complex(false);
01793         ret->set_ri(true);
01794         ret->to_zero();
01795 
01796         cube = ret->get_data();
01797         // cb2sph should be replaced by something that touches only ptrs and cord
01798         status = cb2sph(cube, volsize, ri, origin, nnz, ptrs, cord, sphere);
01799         // check status
01800 
01801         for (j = 1; j <= nangles; j++) {
01802                 status = bckpj3(volsize, nrays, nnz, &dm(1,j), origin, ri,
01803                          ptrs   , cord , &images(1,1,j), sphere);
01804         // check status?
01805         }
01806 
01807         status = sph2cb(sphere, volsize, nrays, ri, nnz, ptrs, cord, cube);
01808         // check status?
01809 
01810         // deallocate all temporary work space
01811         EMDeleteArray(dm);
01812         EMDeleteArray(ptrs);
01813         EMDeleteArray(cord);
01814         EMDeleteArray(sphere);
01815 
01816         ret->update();
01817         return ret;
01818 }

string EMAN::ChaoProjector::get_name (  )  const [inline, virtual]

Get the projector's name.

Each projector is indentified by unique name.

Returns:
The projector's name.

Implements EMAN::Projector.

Definition at line 371 of file projector.h.

00372                 {
00373                         return "chao";
00374                 }

string EMAN::ChaoProjector::get_desc (  )  const [inline, virtual]

Implements EMAN::Projector.

Definition at line 376 of file projector.h.

00377                 {
00378                         return "Fast real space projection generation with Bi-Linear interpolation.";
00379                 }

static Projector* EMAN::ChaoProjector::NEW (  )  [inline, static]

Definition at line 381 of file projector.h.

00382                 {
00383                         return new ChaoProjector();
00384                 }

TypeDict EMAN::ChaoProjector::get_param_types (  )  const [inline, virtual]

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Projector.

Definition at line 386 of file projector.h.

References EMAN::EMObject::FLOAT, EMAN::EMObject::FLOATARRAY, EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::TRANSFORM.

00387                 {
00388                         TypeDict d;
00389                         d.put("transform", EMObject::TRANSFORM);
00390                         d.put("origin_x",  EMObject::INT);
00391                         d.put("origin_y",  EMObject::INT);
00392                         d.put("origin_z",  EMObject::INT);
00393                         d.put("anglelist", EMObject::FLOATARRAY);
00394                         d.put("radius",    EMObject::FLOAT);
00395                         return d;
00396                 }

int ChaoProjector::getnnz ( Vec3i  volsize,
int  ri,
Vec3i  origin,
int *  nray,
int *  nnz 
) const [private]

Definition at line 1227 of file projector.cpp.

References nnz, nrays, nx, ny, and status.

Referenced by backproject3d(), and project3d().

01229           : count the number of voxels within a sphere centered
01230             at origin and with a radius ri.
01231 
01232      input:
01233      volsize contains the size information (nx,ny,nz) about the volume
01234      ri      radius of the object embedded in the cube.
01235      origin  coordinates for the center of the volume
01236 
01237      output:
01238      nnz    total number of voxels within the sphere (of radius ri)
01239      nrays  number of rays in z-direction.
01240 */
01241 {
01242         int  ix, iy, iz, rs, r2, xs, ys, zs, xx, yy, zz;
01243         int  ftm=0, status = 0;
01244 
01245         r2    = ri*ri;
01246         *nnz  = 0;
01247         *nrays = 0;
01248         int nx = (int)volsize[0];
01249         int ny = (int)volsize[1];
01250         int nz = (int)volsize[2];
01251 
01252         int xcent = (int)origin[0];
01253         int ycent = (int)origin[1];
01254         int zcent = (int)origin[2];
01255 
01256         // need to add some error checking
01257         for (ix = 1; ix <=nx; ix++) {
01258             xs  = ix-xcent;
01259             xx  = xs*xs;
01260             for (iy = 1; iy <= ny; iy++) {
01261                 ys = iy-ycent;
01262                 yy = ys*ys;
01263                 ftm = 1;
01264                 for (iz = 1; iz <= nz; iz++) {
01265                     zs = iz-zcent;
01266                     zz = zs*zs;
01267                     rs = xx + yy + zz;
01268                     if (rs <= r2) {
01269                         (*nnz)++;
01270                         if (ftm) {
01271                            (*nrays)++;
01272                            ftm = 0;
01273                         }
01274                     }
01275                 }
01276             } // end for iy
01277         } // end for ix
01278         return status;
01279 }

int ChaoProjector::cb2sph ( float *  cube,
Vec3i  volsize,
int  ri,
Vec3i  origin,
int  nnz0,
int *  ptrs,
int *  cord,
float *  sphere 
) const [private]

Definition at line 1287 of file projector.cpp.

References cord, cube, nnz, nrays, nx, ny, ptrs, sphere, and status.

Referenced by backproject3d(), and project3d().

01289 {
01290     int    xs, ys, zs, xx, yy, zz, rs, r2;
01291     int    ix, iy, iz, jnz, nnz, nrays;
01292     int    ftm = 0, status = 0;
01293 
01294     int xcent = (int)origin[0];
01295     int ycent = (int)origin[1];
01296     int zcent = (int)origin[2];
01297 
01298     int nx = (int)volsize[0];
01299     int ny = (int)volsize[1];
01300     int nz = (int)volsize[2];
01301 
01302     r2      = ri*ri;
01303     nnz     = 0;
01304     nrays    = 0;
01305     ptrs(1) = 1;
01306 
01307     for (ix = 1; ix <= nx; ix++) {
01308        xs  = ix-xcent;
01309        xx  = xs*xs;
01310        for ( iy = 1; iy <= ny; iy++ ) {
01311            ys = iy-ycent;
01312            yy = ys*ys;
01313            jnz = 0;
01314 
01315            ftm = 1;
01316            // not the most efficient implementation
01317            for (iz = 1; iz <= nz; iz++) {
01318                zs = iz-zcent;
01319                zz = zs*zs;
01320                rs = xx + yy + zz;
01321                if (rs <= r2) {
01322                   jnz++;
01323                   nnz++;
01324                   sphere(nnz) = cube(iz, iy, ix);
01325 
01326                   //  record the coordinates of the first nonzero ===
01327                   if (ftm) {
01328                      nrays++;
01329                      cord(1,nrays) = iz;
01330                      cord(2,nrays) = iy;
01331                      cord(3,nrays) = ix;
01332                      ftm = 0;
01333                   }
01334                }
01335             } // end for (iz..)
01336             if (jnz > 0) {
01337                 ptrs(nrays+1) = ptrs(nrays) + jnz;
01338             }  // endif (jnz)
01339        } // end for iy
01340     } // end for ix
01341     if (nnz != nnz0) status = -1;
01342     return status;
01343 }

int ChaoProjector::sph2cb ( float *  sphere,
Vec3i  volsize,
int  nray,
int  ri,
int  nnz0,
int *  ptrs,
int *  cord,
float *  cube 
) const [private]

Definition at line 1346 of file projector.cpp.

References cord, cube, nnz, nx, ny, ptrs, sphere, and status.

Referenced by backproject3d().

01348 {
01349     int       status=0;
01350     int       r2, i, j, ix, iy, iz,  nnz;
01351 
01352     int nx = (int)volsize[0];
01353     int ny = (int)volsize[1];
01354     // int nz = (int)volsize[2];
01355 
01356     r2      = ri*ri;
01357     nnz     = 0;
01358     ptrs(1) = 1;
01359 
01360     // no need to initialize
01361     // for (i = 0; i<nx*ny*nz; i++) cube[i]=0.0;
01362 
01363     nnz = 0;
01364     for (j = 1; j <= nrays; j++) {
01365        iz = cord(1,j);
01366        iy = cord(2,j);
01367        ix = cord(3,j);
01368        for (i = ptrs(j); i<=ptrs(j+1)-1; i++, iz++) {
01369            nnz++;
01370            cube(iz,iy,ix) = sphere(nnz);
01371        }
01372     }
01373     if (nnz != nnz0) status = -1;
01374     return status;
01375 }

int ChaoProjector::fwdpj3 ( Vec3i  volsize,
int  nray,
int  nnz,
float *  dm,
Vec3i  origin,
int  ri,
int *  ptrs,
int *  cord,
float *  x,
float *  y 
) const [private]

Definition at line 1381 of file projector.cpp.

References cord, dm, ifix(), nx, ptrs, status, x, and y.

Referenced by project3d().

01384 {
01385     /*
01386         purpose:  y <--- proj(x)
01387         input  :  volsize  the size (nx,ny,nz) of the volume
01388                   nrays    number of rays within the compact spherical
01389                            representation
01390                   nnz      number of voxels within the sphere
01391                   dm       an array of size 9 storing transformation
01392                            associated with the projection direction
01393                   origin   coordinates of the center of the volume
01394                   ri       radius of the sphere
01395                   ptrs     the beginning address of each ray
01396                   cord     the coordinates of the first point in each ray
01397                   x        3d input volume
01398                   y        2d output image
01399     */
01400 
01401     int    iqx, iqy, i, j, xc, yc, zc;
01402     float  ct, dipx, dipy, dipx1m, dipy1m, xb, yb, dm1, dm4;
01403     int    status = 0;
01404 
01405     int xcent = origin[0];
01406     int ycent = origin[1];
01407     int zcent = origin[2];
01408 
01409     int nx = volsize[0];
01410 
01411     dm1 = dm(1);
01412     dm4 = dm(4);
01413 
01414     if ( nx > 2*ri ) {
01415         for (i = 1; i <= nrays; i++) {
01416             zc = cord(1,i)-zcent;
01417             yc = cord(2,i)-ycent;
01418             xc = cord(3,i)-xcent;
01419 
01420             xb = zc*dm(1)+yc*dm(2)+xc*dm(3) + xcent;
01421             yb = zc*dm(4)+yc*dm(5)+xc*dm(6) + ycent;
01422 
01423             for (j = ptrs(i); j< ptrs(i+1); j++) {
01424                iqx = ifix(xb);
01425                iqy = ifix(yb);
01426 
01427                ct   = x(j);
01428                dipx =  xb - (float)(iqx);
01429                dipy = (yb - (float)(iqy)) * ct;
01430 
01431                dipy1m = ct - dipy;
01432                dipx1m = 1.0f - dipx;
01433 
01434                y(iqx  ,iqy)   = y(iqx  ,iqy)   + dipx1m*dipy1m;
01435                y(iqx+1,iqy)   = y(iqx+1,iqy)   + dipx*dipy1m;
01436                y(iqx+1,iqy+1) = y(iqx+1,iqy+1) + dipx*dipy;
01437                y(iqx  ,iqy+1) = y(iqx  ,iqy+1) + dipx1m*dipy;
01438 
01439                xb += dm1;
01440                yb += dm4;
01441            }
01442         }
01443     }
01444     else {
01445         fprintf(stderr, " nx must be greater than 2*ri\n");
01446         exit(1);
01447     }
01448     return status;
01449 }

int ChaoProjector::bckpj3 ( Vec3i  volsize,
int  nray,
int  nnz,
float *  dm,
Vec3i  origin,
int  ri,
int *  ptrs,
int *  cord,
float *  x,
float *  y 
) const [private]

Definition at line 1457 of file projector.cpp.

References cord, dm, ifix(), nx, ptrs, status, x, and y.

Referenced by backproject3d().

01460 {
01461     int       i, j, iqx,iqy, xc, yc, zc;
01462     float     xb, yb, dx, dy, dx1m, dy1m, dxdy;
01463     int       status = 0;
01464 
01465     int xcent = origin[0];
01466     int ycent = origin[1];
01467     int zcent = origin[2];
01468 
01469     int nx = volsize[0];
01470 
01471     if ( nx > 2*ri) {
01472         for (i = 1; i <= nrays; i++) {
01473             zc = cord(1,i) - zcent;
01474             yc = cord(2,i) - ycent;
01475             xc = cord(3,i) - xcent;
01476 
01477             xb = zc*dm(1)+yc*dm(2)+xc*dm(3) + xcent;
01478             yb = zc*dm(4)+yc*dm(5)+xc*dm(6) + ycent;
01479 
01480             for (j = ptrs(i); j <ptrs(i+1); j++) {
01481                 iqx = ifix((float)(xb));
01482                 iqy = ifix((float)(yb));
01483 
01484                 dx = xb - (float)(iqx);
01485                 dy = yb - (float)(iqy);
01486                 dx1m = 1.0f - dx;
01487                 dy1m = 1.0f - dy;
01488                 dxdy = dx*dy;
01489 /*
01490 c               y(j) = y(j) + dx1m*dy1m*x(iqx  , iqy)
01491 c     &                     + dx1m*dy  *x(iqx  , iqy+1)
01492 c     &                     + dx  *dy1m*x(iqx+1, iqy)
01493 c     &                     + dx  *dy  *x(iqx+1, iqy+1)
01494 c
01495 c              --- faster version of the above commented out
01496 c                  code (derived by summing the following table
01497 c                  of coefficients along  the colunms) ---
01498 c
01499 c                        1         dx        dy      dxdy
01500 c                     ------   --------  --------  -------
01501 c                      x(i,j)   -x(i,j)   -x(i,j)    x(i,j)
01502 c                                        x(i,j+1) -x(i,j+1)
01503 c                              x(i+1,j)           -x(i+1,j)
01504 c                                                x(i+1,j+1)
01505 c
01506 */
01507                y(j) += x(iqx,iqy)
01508                     +  dx*(-x(iqx,iqy)+x(iqx+1,iqy))
01509                     +  dy*(-x(iqx,iqy)+x(iqx,iqy+1))
01510                     +  dxdy*( x(iqx,iqy) - x(iqx,iqy+1)
01511                              -x(iqx+1,iqy) + x(iqx+1,iqy+1) );
01512 
01513                xb += dm(1);
01514                yb += dm(4);
01515             } // end for j
01516         } // end for i
01517      }
01518     else {
01519         fprintf(stderr, "bckpj3: nx must be greater than 2*ri\n");
01520     }
01521 
01522     return status;
01523 }

int ChaoProjector::ifix ( float  a  )  const [private]

Definition at line 1530 of file projector.cpp.

Referenced by bckpj3(), and fwdpj3().

01531 {
01532     int ia;
01533 
01534     if (a>=0) {
01535        ia = (int)floor(a);
01536     }
01537     else {
01538        ia = (int)ceil(a);
01539     }
01540     return ia;
01541 }

void ChaoProjector::setdm ( vector< float >  anglelist,
string const  angletype,
float *  dm 
) const [private]

Definition at line 1547 of file projector.cpp.

References anglelist, dgr_to_rad, dm, phi, and theta.

Referenced by backproject3d(), and project3d().

01548 { // convert Euler angles to transformations, dm is an 9 by nangles array
01549 
01550         float  psi, theta, phi;
01551         double cthe, sthe, cpsi, spsi, cphi, sphi;
01552         int    j;
01553 
01554         int nangles = anglelist.size() / 3;
01555 
01556         // now convert all angles
01557         for (j = 1; j <= nangles; j++) {
01558                 phi   = static_cast<float>(anglelist(1,j)*dgr_to_rad);
01559                 theta = static_cast<float>(anglelist(2,j)*dgr_to_rad);
01560                 psi   = static_cast<float>(anglelist(3,j)*dgr_to_rad);
01561 
01562                 //              cout << phi << " " << theta << " " << psi << endl;
01563                 cthe  = cos(theta);
01564                 sthe  = sin(theta);
01565                 cpsi  = cos(psi);
01566                 spsi  = sin(psi);
01567                 cphi  = cos(phi);
01568                 sphi  = sin(phi);
01569 
01570                 dm(1,j)=static_cast<float>(cphi*cthe*cpsi-sphi*spsi);
01571                 dm(2,j)=static_cast<float>(sphi*cthe*cpsi+cphi*spsi);
01572                 dm(3,j)=static_cast<float>(-sthe*cpsi);
01573                 dm(4,j)=static_cast<float>(-cphi*cthe*spsi-sphi*cpsi);
01574                 dm(5,j)=static_cast<float>(-sphi*cthe*spsi+cphi*cpsi);
01575                 dm(6,j)=static_cast<float>(sthe*spsi);
01576                 dm(7,j)=static_cast<float>(sthe*cphi);
01577                 dm(8,j)=static_cast<float>(sthe*sphi);
01578                 dm(9,j)=static_cast<float>(cthe);
01579         }
01580 }


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

Generated on Sat Nov 21 02:20:40 2009 for EMAN2 by  doxygen 1.5.6