Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | Friends | List of all members
Cylinder Class Reference

#include <phantom.h>

Inheritance diagram for Cylinder:
Inheritance graph
[legend]
Collaboration diagram for Cylinder:
Collaboration graph
[legend]

Public Member Functions

void prepare ()
 
void assign (const Cylinder &F)
 
int point_inside (const Matrix1D< double > &r, Matrix1D< double > &aux) const
 
double density_inside (const Matrix1D< double > &r, Matrix1D< double > &aux) const
 
Featurescale (double factor) const
 
 __attribute__ ((deprecated)) void scale(double factor
 
double intersection (const Matrix1D< double > &direction, const Matrix1D< double > &passing_point, Matrix1D< double > &r, Matrix1D< double > &u) const
 
double volume () const
 
void read_specific (char *line)
 
void read_specific (const std::vector< double > &vect)
 
void feat_printf (FILE *fh) const
 
void feat_printm (MetaData &MD, size_t id)
 
void init_rnd (double minxradius, double maxxradius, double minyradius, double maxyradius, double minheight, double maxheight, double minden=1.0, double maxden=1.0, double minx0=0, double maxx0=0, double miny0=0, double maxy0=0, double minz0=0, double maxz0=0, double minrot=0, double maxrot=360, double mintilt=0, double maxtilt=180, double minpsi=0, double maxpsi=360)
 
- Public Member Functions inherited from Oriented_Feature
void prepare_Euler ()
 
void assign (const Oriented_Feature &OF)
 
virtual void rotate (const Matrix2D< double > &E)
 
- Public Member Functions inherited from Feature
void assign (const Feature &F)
 
virtual void rotate_center (const Matrix2D< double > &E)
 
int point_inside (const Matrix1D< double > &r) const
 
int voxel_inside (const Matrix1D< double > &r, Matrix1D< double > &aux1, Matrix1D< double > &aux2) const
 
int voxel_inside (const Matrix1D< double > &r) const
 
double voxel_inside_by_normalized_density (const Matrix1D< double > &r, Matrix1D< double > &aux1, Matrix1D< double > &aux2) const
 
int intersects_sphere (const Matrix1D< double > &r, double radius, Matrix1D< double > &aux1, Matrix1D< double > &aux2, Matrix1D< double > &aux3) const
 
int intersects_sphere (const Matrix1D< double > &r, double radius) const
 
Featureencircle (double radius=0) const
 
Featurebackground (int back_mode, double back_param) const
 
double intersection (const Matrix1D< double > &direction, const Matrix1D< double > &passing_point) const
 
void mean_variance_in_plane (Image< double > *V, double z, double &mean, double &var)
 
void project_to (Projection &P, const Matrix2D< double > &VP, const Matrix2D< double > &PV) const
 
void corners (const MultidimArray< double > &V, Matrix1D< double > &corner1, Matrix1D< double > &corner2)
 
void draw_in (MultidimArray< double > &V, int color_mode=INTERNAL, double colour=-1)
 
void sketch_in (MultidimArray< double > &V, double colour=2)
 
void shift (double shiftX, double shiftY, double shiftZ)
 
void selfApplyGeometry (const Matrix2D< double > &A)
 
void readCommon (char *line)
 
void readCommon (MDRow &row)
 
void read (MDRow &row)
 

Public Attributes

double xradius
 Cylinder X radius. More...
 
double yradius
 Cylinder Y radius. More...
 
double height
 Cylinder height. More...
 
Feature **_f const
 
- Public Attributes inherited from Oriented_Feature
double rot
 First Euler angle. More...
 
double tilt
 Second Euler angle. More...
 
double psi
 Third Euler angle. More...
 
Matrix2D< double > euler
 Euler matrix. More...
 
Matrix2D< double > eulert
 Inverse Euler matrix. More...
 
- Public Attributes inherited from Feature
std::string type
 
char add_assign
 
double density
 
Matrix1D< double > center
 
double max_distance
 

Friends

std::ostream & operator<< (std::ostream &o, const Cylinder &f)
 

Detailed Description

Cylinder. A cylinder is defined by its center, a radius, a height and a set of Euler angles, label="cyl". The center of the cylinder is at the geometrical center, ie, first the cylinder is placed with its base parallel to XY plane (the base is of radius "radius"), and the cylinder is defined between "-height/2" to "+height/2". Then the cylinder is rotated after the three Euler angles.

A point (r) in the universal coordinate system, where cylinders are defined in general, can be expressed (rp) with respect to a system where the cylinder is centered at the origin, its radius and height are unity and its base is parallel to the XY plane by

V3_MINUS_V3(rp,r,cyl.Center);
M3x3_BY_V3x1(rp,cyl.euler,rp);
XX(rp) /= cyl.radius;
YY(rp) /= cyl.radius;
ZZ(rp) /= cyl.height;

Directions (free vectors) are transformed in the same fashion except that for the first vector subtraction (referring the origin).

Definition at line 762 of file phantom.h.

Member Function Documentation

◆ __attribute__()

Cylinder::__attribute__ ( (deprecated)  )

Another function for return a scaled cylinder.

◆ assign()

void Cylinder::assign ( const Cylinder F)

Another function for assignment.

Definition at line 123 of file phantom.cpp.

124 {
125  *this = F;
126 }

◆ density_inside()

double Cylinder::density_inside ( const Matrix1D< double > &  r,
Matrix1D< double > &  aux 
) const
inlinevirtual

Density inside an cylinder. This function tells you the density of the cylinder at point r for constant valued features is trivial

Implements Feature.

Definition at line 791 of file phantom.h.

792  {
793  return 1.;
794  }

◆ feat_printf()

void Cylinder::feat_printf ( FILE *  fh) const
virtual

Print cylinder in the standard feature format. \ See {Feature::feat_printf}, Phantoms

Implements Feature.

Definition at line 456 of file phantom.cpp.

457 {
458  fprintf(fh, "cyl %c %1.4f % 7.2f % 7.2f % 7.2f % 7.2f "
459  "% 7.2f % 7.2f % 7.2f % 7.2f % 7.2f\n",
462  rot, tilt, psi);
463 }
double tilt
Second Euler angle.
Definition: phantom.h:430
Matrix1D< double > center
Definition: phantom.h:119
double density
Definition: phantom.h:114
char add_assign
Definition: phantom.h:108
#define XX(v)
Definition: matrix1d.h:85
double height
Cylinder height.
Definition: phantom.h:772
#define YY(v)
Definition: matrix1d.h:93
double yradius
Cylinder Y radius.
Definition: phantom.h:769
double rot
First Euler angle.
Definition: phantom.h:427
double psi
Third Euler angle.
Definition: phantom.h:433
fprintf(glob_prnt.io, "\)
#define ZZ(v)
Definition: matrix1d.h:101
double xradius
Cylinder X radius.
Definition: phantom.h:766

◆ feat_printm()

void Cylinder::feat_printm ( MetaData MD,
size_t  id 
)
virtual

Implements Feature.

Definition at line 466 of file phantom.cpp.

467 {
468  std::vector<double> FSVect;
469  FSVect.push_back(xradius);
470  FSVect.push_back(yradius);
471  FSVect.push_back(height);
472  FSVect.push_back(rot);
473  FSVect.push_back(tilt);
474  FSVect.push_back(psi);
476 }
double tilt
Second Euler angle.
Definition: phantom.h:430
double height
Cylinder height.
Definition: phantom.h:772
Specific parameters for a feature (vector double)
bool setValue(const MDLabel label, const T &valueIn, size_t id)
double yradius
Cylinder Y radius.
Definition: phantom.h:769
double rot
First Euler angle.
Definition: phantom.h:427
double psi
Third Euler angle.
Definition: phantom.h:433
double xradius
Cylinder X radius.
Definition: phantom.h:766

◆ init_rnd()

void Cylinder::init_rnd ( double  minxradius,
double  maxxradius,
double  minyradius,
double  maxyradius,
double  minheight,
double  maxheight,
double  minden = 1.0,
double  maxden = 1.0,
double  minx0 = 0,
double  maxx0 = 0,
double  miny0 = 0,
double  maxy0 = 0,
double  minz0 = 0,
double  maxz0 = 0,
double  minrot = 0,
double  maxrot = 360,
double  mintilt = 0,
double  maxtilt = 180,
double  minpsi = 0,
double  maxpsi = 360 
)

Generate a random cylinder. A cylinder is generated randomly within the range of the parameters given. Notice that most of them are set by default. The exact parameters are picked uniformly from the range. The maximum distance is adjusted properly according to the randomly generated feature. 'den' stands for density and (x0,y0,z0) is the center of the feature. The behaviour of the new sphere is always Add

Definition at line 1746 of file phantom.cpp.

1757 {
1759  center.resize(3);
1760  type = "cyl";
1761  add_assign = '+';
1762  density = rnd_unif(minden, maxden);
1763  XX(center) = rnd_unif(minx0, maxx0);
1764  YY(center) = rnd_unif(miny0, maxy0);
1765  ZZ(center) = rnd_unif(minz0, maxz0);
1766 
1767  xradius = rnd_unif(minxradius, maxxradius);
1768  yradius = rnd_unif(minyradius, maxyradius);
1769  height = rnd_unif(minheight, maxheight);
1770  rot = rnd_unif(minrot, maxrot);
1771  tilt = rnd_unif(mintilt, maxtilt);
1772  psi = rnd_unif(minpsi, maxpsi);
1774  eulert = euler.transpose();
1775 
1777 }
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
Matrix2D< double > eulert
Inverse Euler matrix.
Definition: phantom.h:439
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
Definition: geometry.cpp:624
double tilt
Second Euler angle.
Definition: phantom.h:430
Matrix2D< double > euler
Euler matrix.
Definition: phantom.h:436
void sqrt(Image< double > &op)
Matrix1D< double > center
Definition: phantom.h:119
double density
Definition: phantom.h:114
Matrix2D< T > transpose() const
Definition: matrix2d.cpp:1314
char add_assign
Definition: phantom.h:108
double rnd_unif()
#define XX(v)
Definition: matrix1d.h:85
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
double height
Cylinder height.
Definition: phantom.h:772
double max_distance
Definition: phantom.h:126
#define YY(v)
Definition: matrix1d.h:93
double yradius
Cylinder Y radius.
Definition: phantom.h:769
std::string type
Definition: phantom.h:101
double rot
First Euler angle.
Definition: phantom.h:427
double psi
Third Euler angle.
Definition: phantom.h:433
unsigned int randomize_random_generator()
#define ZZ(v)
Definition: matrix1d.h:101
double xradius
Cylinder X radius.
Definition: phantom.h:766

◆ intersection()

double Cylinder::intersection ( const Matrix1D< double > &  direction,
const Matrix1D< double > &  passing_point,
Matrix1D< double > &  r,
Matrix1D< double > &  u 
) const
virtual

Intersection of a ray with a cylinder. See Feature::intersection to know more about the parameters meaning.

Implements Feature.

Definition at line 1143 of file phantom.cpp.

1148 {
1149  double norm = direction.module();
1151 
1152  // Set the passing point in the cylinder coordinate system
1153  // and normalise to a unit cylinder
1154  V3_MINUS_V3(r, passing_point, center);
1155  M3x3_BY_V3x1(r, euler, r);
1156  XX(r) /= xradius;
1157  YY(r) /= yradius;
1158  ZZ(r) /= height;
1159 
1160  // Express also the direction in the cyilinder coordinate system
1161  // and normalise to a unit cylinder
1162  M3x3_BY_V3x1(u, euler, direction);
1163  XX(u) /= xradius;
1164  YY(u) /= yradius;
1165  ZZ(u) /= height;
1166 
1167 #ifdef DEBUG
1168 
1169  std::cout << "Intersecting .-.-.-.-.-.-.\n";
1170  std::cout << *this;
1171  std::cout << " direction(Univ) = " << direction.transpose() << std::endl;
1172  std::cout << " passing (Univ) = " << passing_point.transpose() << std::endl;
1173  std::cout << " direction(Obj.) = " << u.transpose() << std::endl;
1174  std::cout << " passing (Obj.) = " << r.transpose() << std::endl;
1175  std::cout << " intersection = " << intersection_unit_cylinder(u, r) << std::endl;
1176 #endif
1177 
1178  return intersection_unit_cylinder(u, r) / norm;
1179 }
double module() const
Definition: matrix1d.h:983
Matrix2D< double > euler
Euler matrix.
Definition: phantom.h:436
#define V3_MINUS_V3(a, b, c)
Definition: matrix1d.h:202
Matrix1D< double > center
Definition: phantom.h:119
double intersection_unit_cylinder(const Matrix1D< double > &u, const Matrix1D< double > &r)
Definition: geometry.cpp:1151
T norm(const std::vector< T > &v)
Definition: vector_ops.h:399
Matrix1D< T > transpose() const
Definition: matrix1d.cpp:644
#define XX(v)
Definition: matrix1d.h:85
double height
Cylinder height.
Definition: phantom.h:772
#define M3x3_BY_V3x1(a, M, b)
Definition: matrix2d.h:170
#define YY(v)
Definition: matrix1d.h:93
double yradius
Cylinder Y radius.
Definition: phantom.h:769
#define ZZ(v)
Definition: matrix1d.h:101
double xradius
Cylinder X radius.
Definition: phantom.h:766
#define SPEED_UP_temps012
Definition: xmipp_macros.h:403

◆ point_inside()

int Cylinder::point_inside ( const Matrix1D< double > &  r,
Matrix1D< double > &  aux 
) const
virtual

Speeded up point inside a cylinder. This function tells you if a point is inside the cylinder or not. See Feature::point_inside

Implements Feature.

Definition at line 738 of file phantom.cpp.

739 {
741  double tx;
742  double ty;
743 
744  // Express r in the feature coord. system
745  V3_MINUS_V3(aux, r, center);
746  M3x3_BY_V3x1(aux, euler, aux);
747 
748  // Check if it is inside
749  tx = XX(aux) / xradius;
750  ty = YY(aux) / yradius;
751  if (tx*tx + ty*ty <= 1.0 && fabs(ZZ(aux)) <= height / 2)
752  return 1;
753  return 0;
754 }
Matrix2D< double > euler
Euler matrix.
Definition: phantom.h:436
#define V3_MINUS_V3(a, b, c)
Definition: matrix1d.h:202
Matrix1D< double > center
Definition: phantom.h:119
#define XX(v)
Definition: matrix1d.h:85
double height
Cylinder height.
Definition: phantom.h:772
#define M3x3_BY_V3x1(a, M, b)
Definition: matrix2d.h:170
#define YY(v)
Definition: matrix1d.h:93
double yradius
Cylinder Y radius.
Definition: phantom.h:769
#define ZZ(v)
Definition: matrix1d.h:101
double xradius
Cylinder X radius.
Definition: phantom.h:766
#define SPEED_UP_temps012
Definition: xmipp_macros.h:403

◆ prepare()

void Cylinder::prepare ( )
virtual

Prepare cylinder for work. Computes the maximum distance, in this case, equal to "sqrt(height*height/4+radius*radius)", and computes the Euler and inverse Euler matrices as a function of the Euler angles

Implements Feature.

Definition at line 59 of file phantom.cpp.

60 {
61  prepare_Euler();
63 }
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
void sqrt(Image< double > &op)
double height
Cylinder height.
Definition: phantom.h:772
double max_distance
Definition: phantom.h:126
double yradius
Cylinder Y radius.
Definition: phantom.h:769
void prepare_Euler()
Definition: phantom.cpp:102
double xradius
Cylinder X radius.
Definition: phantom.h:766

◆ read_specific() [1/2]

void Cylinder::read_specific ( char *  line)

Read specific description for a cylinder. An exception is thrown if the line doesn't conform the standard specification. See Feature::read_specific

Definition at line 283 of file phantom.cpp.

284 {
285  int stat;
286  stat = sscanf(line, "%*s %*c %*f %*f %*f %*f %lf %lf %lf %lf %lf %lf", &xradius,
287  &yradius, &height, &rot, &tilt, &psi);
288  if (stat != 6)
289  REPORT_ERROR(ERR_IO_NOREAD, (std::string)"Error when reading a cylinder:" + line);
290  prepare();
291 }
void prepare()
Definition: phantom.cpp:59
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double tilt
Second Euler angle.
Definition: phantom.h:430
double height
Cylinder height.
Definition: phantom.h:772
Couldn&#39;t read from file.
Definition: xmipp_error.h:139
double yradius
Cylinder Y radius.
Definition: phantom.h:769
double rot
First Euler angle.
Definition: phantom.h:427
double psi
Third Euler angle.
Definition: phantom.h:433
double xradius
Cylinder X radius.
Definition: phantom.h:766

◆ read_specific() [2/2]

void Cylinder::read_specific ( const std::vector< double > &  vector)
virtual

Read a feature from a file, VIRTUAL!!!. The format must be the one given in Phantoms, and each subclass must implement its own I/O routines. These routines must fill only the non common part of the feature description, but they receive the whole line with the description.

Implements Feature.

Definition at line 294 of file phantom.cpp.

295 {
296  if (vect.size() != 6)
297  REPORT_ERROR(ERR_ARG_MISSING, MDL::label2Str(MDL_PHANTOM_FEATURE_SPECIFIC) + "Error when reading a cylinder");
298  xradius = vect[0];
299  yradius = vect[1];
300  height = vect[2];
301  rot = vect[3];
302  tilt = vect[4];
303  psi = vect[5];
304  prepare();
305 }
Argument missing.
Definition: xmipp_error.h:114
void prepare()
Definition: phantom.cpp:59
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double tilt
Second Euler angle.
Definition: phantom.h:430
double height
Cylinder height.
Definition: phantom.h:772
Specific parameters for a feature (vector double)
double yradius
Cylinder Y radius.
Definition: phantom.h:769
double rot
First Euler angle.
Definition: phantom.h:427
double psi
Third Euler angle.
Definition: phantom.h:433
static String label2Str(const MDLabel &label)
double xradius
Cylinder X radius.
Definition: phantom.h:766

◆ scale()

void Cylinder::scale ( double  factor) const
virtual

Return a scaled cylinder. The center, density, angles and behaviour of the new cylinder is exactly the same as the actual one. The radius and height are multiplied by the scale factor and the maximum distance is recalculated for the new cylinder.

Implements Feature.

Definition at line 1538 of file phantom.cpp.

1539 {
1540  Cylinder *f;
1541  f = new Cylinder;
1543  COPY_ANGLES;
1544 
1545  f->xradius = factor * xradius;
1546  f->yradius = factor * yradius;
1547  f->height = factor * height;
1548  f->prepare();
1549  return (Feature *)f;
1550 }
void prepare()
Definition: phantom.cpp:59
#define COPY_COMMON_PART
Definition: phantom.cpp:1473
double * f
double height
Cylinder height.
Definition: phantom.h:772
double yradius
Cylinder Y radius.
Definition: phantom.h:769
#define COPY_ANGLES
Definition: phantom.cpp:1479
double xradius
Cylinder X radius.
Definition: phantom.h:766

◆ volume()

double Cylinder::volume ( ) const
inlinevirtual

Volume of a cylinder. This function returns 4/3*PI*radius*radius*height. See Feature::volume

Implements Feature.

Definition at line 815 of file phantom.h.

816  {
817  return 4 / 3*PI*xradius*yradius*height;
818  }
double height
Cylinder height.
Definition: phantom.h:772
double yradius
Cylinder Y radius.
Definition: phantom.h:769
#define PI
Definition: tools.h:43
double xradius
Cylinder X radius.
Definition: phantom.h:766

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  o,
const Cylinder f 
)
friend

Show feature not in the standard format but more informatively. This function only shows the non common part of the feature. Use the << operator of Feature to show the whole feature.

Definition at line 622 of file phantom.cpp.

623 {
624  o << " XRadius: " << f.xradius << std::endl;
625  o << " YRadius: " << f.yradius << std::endl;
626  o << " Height: " << f.height << std::endl;
627  o << " Rot: " << f.rot << std::endl;
628  o << " Tilt: " << f.tilt << std::endl;
629  o << " Psi: " << f.psi << std::endl;
630  return o;
631 }
double tilt
Second Euler angle.
Definition: phantom.h:430
double height
Cylinder height.
Definition: phantom.h:772
double yradius
Cylinder Y radius.
Definition: phantom.h:769
double rot
First Euler angle.
Definition: phantom.h:427
double psi
Third Euler angle.
Definition: phantom.h:433
double xradius
Cylinder X radius.
Definition: phantom.h:766

Member Data Documentation

◆ const

Feature** _f Cylinder::const

Definition at line 803 of file phantom.h.

◆ height

double Cylinder::height

Cylinder height.

Definition at line 772 of file phantom.h.

◆ xradius

double Cylinder::xradius

Cylinder X radius.

Definition at line 766 of file phantom.h.

◆ yradius

double Cylinder::yradius

Cylinder Y radius.

Definition at line 769 of file phantom.h.


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