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

#include <phantom.h>

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

Public Member Functions

void prepare ()
 
void assign (const DCylinder &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 minradius, double maxradius, double minheight, double maxheight, double minsep, double maxsep, 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 radius
 Cylinder radius. More...
 
double height
 Each cylinder height. More...
 
double separation
 Separation between cylinders. 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 DCylinder &f)
 

Detailed Description

Double cylinders. A double cylinder is defined by its center, a radius, a height and a set of Euler angles, label="dcy". The double cylinder are two cylinders whose centers are (before rotating) "+separation/2+height/2" and "-separation/2-height/2" respectively. Ie, two cylinders along Z axis of height "height" and separated "separation" units. These two cylinders are 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" starting from their own centers. Then the cylinders, as a block, are 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 FIRST cylinder is centered at the origin, its radius is unity and its base is parallel to the XY plane (notice that the height is not transformed) by

V3_MINUS_V3(rp,r,dcy.Center+dcy.);
ZZ(r) -= (separation/2+height/2);
M3x3_BY_V3x1(rp,dcy.euler,rp);
XX(rp) /= dcy.radius;
YY(rp) /= dcy.radius;

and for the SECOND dcyinder

V3_MINUS_V3(rp,r,dcy.Center+dcy.);
ZZ(r) += (separation/2+height/2); // This is the only one line changing
M3x3_BY_V3x1(rp,dcy.euler,rp);
XX(rp) /= dcy.radius;
YY(rp) /= dcy.radius;

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

Definition at line 890 of file phantom.h.

Member Function Documentation

◆ __attribute__()

DCylinder::__attribute__ ( (deprecated)  )

Another function for return a scaled double cylinder.

◆ assign()

void DCylinder::assign ( const DCylinder F)

Another function for assignment.

Definition at line 128 of file phantom.cpp.

129 {
130  *this = F;
131 }

◆ density_inside()

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

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

Implements Feature.

Definition at line 920 of file phantom.h.

921  {
922  return 1.;
923  }

◆ feat_printf()

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

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

Implements Feature.

Definition at line 478 of file phantom.cpp.

479 {
480  fprintf(fh, "dcy %c %1.4f % 7.2f % 7.2f % 7.2f % 7.2f "
481  "% 7.2f % 7.2f % 7.2f % 7.2f % 7.2f\n",
484  rot, tilt, psi);
485 }
double height
Each cylinder height.
Definition: phantom.h:897
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 separation
Separation between cylinders.
Definition: phantom.h:900
#define YY(v)
Definition: matrix1d.h:93
double rot
First Euler angle.
Definition: phantom.h:427
double radius
Cylinder radius.
Definition: phantom.h:894
double psi
Third Euler angle.
Definition: phantom.h:433
fprintf(glob_prnt.io, "\)
#define ZZ(v)
Definition: matrix1d.h:101

◆ feat_printm()

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

Implements Feature.

Definition at line 488 of file phantom.cpp.

489 {
490  std::vector<double> FSVect;
491  FSVect.push_back(radius);
492  FSVect.push_back(height);
493  FSVect.push_back(separation);
494  FSVect.push_back(rot);
495  FSVect.push_back(tilt);
496  FSVect.push_back(psi);
498 }
double height
Each cylinder height.
Definition: phantom.h:897
double tilt
Second Euler angle.
Definition: phantom.h:430
double separation
Separation between cylinders.
Definition: phantom.h:900
Specific parameters for a feature (vector double)
bool setValue(const MDLabel label, const T &valueIn, size_t id)
double rot
First Euler angle.
Definition: phantom.h:427
double radius
Cylinder radius.
Definition: phantom.h:894
double psi
Third Euler angle.
Definition: phantom.h:433

◆ init_rnd()

void DCylinder::init_rnd ( double  minradius,
double  maxradius,
double  minheight,
double  maxheight,
double  minsep,
double  maxsep,
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 double cylinder. A double 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. 'Sep' is the range for the separation

Definition at line 1779 of file phantom.cpp.

1790 {
1792  center.resize(3);
1793  type = "dcy";
1794  add_assign = '+';
1795  density = rnd_unif(minden, maxden);
1796  XX(center) = rnd_unif(minx0, maxx0);
1797  YY(center) = rnd_unif(miny0, maxy0);
1798  ZZ(center) = rnd_unif(minz0, maxz0);
1799 
1800  radius = rnd_unif(minradius, maxradius);
1801  height = rnd_unif(minheight, maxheight);
1802  separation = rnd_unif(minsep, maxsep);
1803  rot = rnd_unif(minrot, maxrot);
1804  tilt = rnd_unif(mintilt, maxtilt);
1805  psi = rnd_unif(minpsi, maxpsi);
1807  eulert = euler.transpose();
1808 
1810  + radius * radius);
1811 }
double height
Each cylinder height.
Definition: phantom.h:897
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 separation
Separation between cylinders.
Definition: phantom.h:900
double max_distance
Definition: phantom.h:126
#define YY(v)
Definition: matrix1d.h:93
std::string type
Definition: phantom.h:101
double rot
First Euler angle.
Definition: phantom.h:427
double radius
Cylinder radius.
Definition: phantom.h:894
double psi
Third Euler angle.
Definition: phantom.h:433
unsigned int randomize_random_generator()
#define ZZ(v)
Definition: matrix1d.h:101

◆ intersection()

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

Intersection of a ray with a double cylinder. See Feature::intersection to know more about the parameters meaning. The ray intersection consider both cylinders, of course.

Implements Feature.

Definition at line 1182 of file phantom.cpp.

1187 {
1188  double norm = direction.module();
1190 
1191  // Express also the direction in the cylinder coordinate system
1192  // and normalise to a unit cylinder
1193  M3x3_BY_V3x1(u, euler, direction);
1194  XX(u) /= radius;
1195  YY(u) /= radius;
1196  ZZ(u) /= height;
1197 
1198  // Top cylinder
1199  // Set the passing point in the cylinder coordinate system
1200  // and normalise to a unit cylinder
1201  V3_MINUS_V3(r, passing_point, center);
1202  M3x3_BY_V3x1(r, euler, r);
1203  ZZ(r) -= (separation / 2 + height / 2);
1204  XX(r) /= radius;
1205  YY(r) /= radius;
1206  ZZ(r) /= height;
1207  double i1 = intersection_unit_cylinder(u, r);
1208 
1209  // Bottom cylinder
1210  // Set the passing point in the cylinder coordinate system
1211  // and normalise to a unit cylinder
1212  V3_MINUS_V3(r, passing_point, center);
1213  M3x3_BY_V3x1(r, euler, r);
1214  ZZ(r) += (separation / 2 + height / 2);
1215  XX(r) /= radius;
1216  YY(r) /= radius;
1217  ZZ(r) /= height;
1218  double i2 = intersection_unit_cylinder(u, r);
1219 
1220  return (i1 + i2) / norm;
1221 }
double height
Each cylinder height.
Definition: phantom.h:897
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
#define XX(v)
Definition: matrix1d.h:85
double separation
Separation between cylinders.
Definition: phantom.h:900
#define M3x3_BY_V3x1(a, M, b)
Definition: matrix2d.h:170
#define YY(v)
Definition: matrix1d.h:93
double radius
Cylinder radius.
Definition: phantom.h:894
#define ZZ(v)
Definition: matrix1d.h:101
#define SPEED_UP_temps012
Definition: xmipp_macros.h:403

◆ point_inside()

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

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

Implements Feature.

Definition at line 757 of file phantom.cpp.

758 {
760 
761  // Express r in the feature coord. system
762  V3_MINUS_V3(aux, r, center);
763  M3x3_BY_V3x1(aux, euler, aux);
764 
765  // Check if inside
766  if (XX(aux)*XX(aux) + YY(aux)*YY(aux) <= radius*radius)
767  {
768  double cyl_center = separation / 2 + height / 2;
769  if (ABS(ZZ(aux) - cyl_center) <= height / 2)
770  return 1;
771  else if (ABS(ZZ(aux) + cyl_center) <= height / 2)
772  return 1;
773  }
774  return 0;
775 }
double height
Each cylinder height.
Definition: phantom.h:897
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
#define ABS(x)
Definition: xmipp_macros.h:142
double separation
Separation between cylinders.
Definition: phantom.h:900
#define M3x3_BY_V3x1(a, M, b)
Definition: matrix2d.h:170
#define YY(v)
Definition: matrix1d.h:93
double radius
Cylinder radius.
Definition: phantom.h:894
#define ZZ(v)
Definition: matrix1d.h:101
#define SPEED_UP_temps012
Definition: xmipp_macros.h:403

◆ prepare()

void DCylinder::prepare ( )
virtual

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

Implements Feature.

Definition at line 65 of file phantom.cpp.

66 {
67  prepare_Euler();
69 }
double height
Each cylinder height.
Definition: phantom.h:897
void sqrt(Image< double > &op)
double separation
Separation between cylinders.
Definition: phantom.h:900
double max_distance
Definition: phantom.h:126
double radius
Cylinder radius.
Definition: phantom.h:894
void prepare_Euler()
Definition: phantom.cpp:102

◆ read_specific() [1/2]

void DCylinder::read_specific ( char *  line)

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

Definition at line 308 of file phantom.cpp.

309 {
310  int stat;
311  stat = sscanf(line, "%*s %*c %*f %*f %*f %*f %lf %lf %lf %lf %lf %lf",
312  &radius, &height, &separation, &rot, &tilt, &psi);
313  if (stat != 6)
314  REPORT_ERROR(ERR_IO_NOREAD, (std::string)"Error when reading a double cylinder:" + line);
315  prepare();
316 }
double height
Each cylinder height.
Definition: phantom.h:897
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double tilt
Second Euler angle.
Definition: phantom.h:430
void prepare()
Definition: phantom.cpp:65
Couldn&#39;t read from file.
Definition: xmipp_error.h:139
double separation
Separation between cylinders.
Definition: phantom.h:900
double rot
First Euler angle.
Definition: phantom.h:427
double radius
Cylinder radius.
Definition: phantom.h:894
double psi
Third Euler angle.
Definition: phantom.h:433

◆ read_specific() [2/2]

void DCylinder::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 319 of file phantom.cpp.

320 {
321  if (vect.size() != 6)
322  REPORT_ERROR(ERR_ARG_MISSING, MDL::label2Str(MDL_PHANTOM_FEATURE_SPECIFIC) + "Error when reading a double cylinder");
323  radius = vect[0];
324  height = vect[1];
325  separation = vect[2];
326  rot = vect[3];
327  tilt = vect[4];
328  psi = vect[5];
329  prepare();
330 }
Argument missing.
Definition: xmipp_error.h:114
double height
Each cylinder height.
Definition: phantom.h:897
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double tilt
Second Euler angle.
Definition: phantom.h:430
void prepare()
Definition: phantom.cpp:65
double separation
Separation between cylinders.
Definition: phantom.h:900
Specific parameters for a feature (vector double)
double rot
First Euler angle.
Definition: phantom.h:427
double radius
Cylinder radius.
Definition: phantom.h:894
double psi
Third Euler angle.
Definition: phantom.h:433
static String label2Str(const MDLabel &label)

◆ scale()

void DCylinder::scale ( double  factor) const
virtual

Return a scaled double cylinder. The center, density, angles and behaviour of the new double 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 double cylinder.

Implements Feature.

Definition at line 1558 of file phantom.cpp.

1559 {
1560  DCylinder *f;
1561  f = new DCylinder;
1563  COPY_ANGLES;
1564 
1565  f->radius = factor * radius;
1566  f->height = factor * height;
1567  f->separation = separation - 2 * (factor - 1) * height;
1568  f->prepare();
1569 
1570  return (Feature *)f;
1571 }
double height
Each cylinder height.
Definition: phantom.h:897
void prepare()
Definition: phantom.cpp:65
#define COPY_COMMON_PART
Definition: phantom.cpp:1473
double * f
double separation
Separation between cylinders.
Definition: phantom.h:900
double radius
Cylinder radius.
Definition: phantom.h:894
#define COPY_ANGLES
Definition: phantom.cpp:1479

◆ volume()

double DCylinder::volume ( ) const
inlinevirtual

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

Implements Feature.

Definition at line 946 of file phantom.h.

947  {
948  return 2* 4 / 3*PI*radius*radius*height;
949  }
double height
Each cylinder height.
Definition: phantom.h:897
double radius
Cylinder radius.
Definition: phantom.h:894
#define PI
Definition: tools.h:43

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  o,
const DCylinder 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 634 of file phantom.cpp.

635 {
636  o << " Radius: " << f.radius << std::endl;
637  o << " Height: " << f.height << std::endl;
638  o << " Separ.: " << f.separation << std::endl;
639  o << " Rot: " << f.rot << std::endl;
640  o << " Tilt: " << f.tilt << std::endl;
641  o << " Psi: " << f.psi << std::endl;
642  return o;
643 }
double height
Each cylinder height.
Definition: phantom.h:897
double tilt
Second Euler angle.
Definition: phantom.h:430
double separation
Separation between cylinders.
Definition: phantom.h:900
double rot
First Euler angle.
Definition: phantom.h:427
double radius
Cylinder radius.
Definition: phantom.h:894
double psi
Third Euler angle.
Definition: phantom.h:433

Member Data Documentation

◆ const

Feature** _f DCylinder::const

Definition at line 934 of file phantom.h.

◆ height

double DCylinder::height

Each cylinder height.

Definition at line 897 of file phantom.h.

◆ radius

double DCylinder::radius

Cylinder radius.

Definition at line 894 of file phantom.h.

◆ separation

double DCylinder::separation

Separation between cylinders.

Definition at line 900 of file phantom.h.


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