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

#include <phantom.h>

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

Public Member Functions

void prepare ()
 
void assign (const Cone &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 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
 Cone base radius. More...
 
double height
 Cone 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 Cone &f)
 

Detailed Description

Cone. A cone is defined by its center, a radius, a height and a set of Euler angles, label="con". The center of the cone is at the geometrical center, ie, first the cone is placed with its base parallel to XY plane (the base is of radius "radius"), and the cone is defined between "-height/2" to "+height/2". Then the cone is rotated after the three Euler angles. The corresponding Euler matrix is stored in the field "euler" while its inverse is in "eulert".

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

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

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

Definition at line 1244 of file phantom.h.

Member Function Documentation

◆ __attribute__()

Cone::__attribute__ ( (deprecated)  )

Another function for return a scaled cone.

◆ assign()

void Cone::assign ( const Cone F)

Another function for assignment.

Definition at line 143 of file phantom.cpp.

144 {
145  *this = F;
146 }

◆ density_inside()

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

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

Implements Feature.

Definition at line 1271 of file phantom.h.

1272  {
1273  return 1.;
1274  }

◆ feat_printf()

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

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

Implements Feature.

Definition at line 546 of file phantom.cpp.

547 {
548  fprintf(fh, "con %c %1.4f % 7.2f % 7.2f % 7.2f % 7.2f "
549  "% 7.2f % 7.2f % 7.2f % 7.2f\n",
551  radius, height,
552  rot, tilt, psi);
553 }
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
Cone height.
Definition: phantom.h:1251
#define YY(v)
Definition: matrix1d.h:93
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 radius
Cone base radius.
Definition: phantom.h:1248

◆ feat_printm()

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

Implements Feature.

Definition at line 556 of file phantom.cpp.

557 {
558  std::vector<double> FSVect;
559  FSVect.push_back(radius);
560  FSVect.push_back(height);
561  FSVect.push_back(rot);
562  FSVect.push_back(tilt);
563  FSVect.push_back(psi);
565 }
double tilt
Second Euler angle.
Definition: phantom.h:430
double height
Cone height.
Definition: phantom.h:1251
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 psi
Third Euler angle.
Definition: phantom.h:433
double radius
Cone base radius.
Definition: phantom.h:1248

◆ init_rnd()

void Cone::init_rnd ( double  minradius,
double  maxradius,
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 cone. A cone 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 1895 of file phantom.cpp.

1905 {
1907  center.resize(3);
1908  type = "con";
1909  add_assign = '+';
1910  density = rnd_unif(minden, maxden);
1911  XX(center) = rnd_unif(minx0, maxx0);
1912  YY(center) = rnd_unif(miny0, maxy0);
1913  ZZ(center) = rnd_unif(minz0, maxz0);
1914 
1915  radius = rnd_unif(minradius, maxradius);
1916  height = rnd_unif(minheight, maxheight);
1917  rot = rnd_unif(minrot, maxrot);
1918  tilt = rnd_unif(mintilt, maxtilt);
1919  psi = rnd_unif(minpsi, maxpsi);
1921  eulert = euler.transpose();
1922 
1924 }
#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
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
double height
Cone height.
Definition: phantom.h:1251
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
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 psi
Third Euler angle.
Definition: phantom.h:433
unsigned int randomize_random_generator()
#define ZZ(v)
Definition: matrix1d.h:101
double radius
Cone base radius.
Definition: phantom.h:1248

◆ intersection()

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

Intersection of a ray with a cone, NOT IMPLEMENTED!!!!. See Feature::intersection to know more about the parameters meaning.

Implements Feature.

Definition at line 1277 of file phantom.cpp.

1282 {
1283  return 0;
1284 }

◆ point_inside()

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

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

Implements Feature.

Definition at line 815 of file phantom.cpp.

816 {
818  double Zradius;
819 
820  // Express r in the feature coord. system
821  V3_MINUS_V3(aux, r, center);
822  M3x3_BY_V3x1(aux, euler, aux);
823 
824  // Check if inside
825  if (ABS(ZZ(aux)) <= height / 2)
826  {
827  Zradius = radius * (1 - (ZZ(aux) + height / 2) / height);
828  if (XX(aux)*XX(aux) + YY(aux)*YY(aux) <= Zradius*Zradius)
829  return 1;
830  }
831  return 0;
832 }
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
Cone height.
Definition: phantom.h:1251
#define ABS(x)
Definition: xmipp_macros.h:142
#define M3x3_BY_V3x1(a, M, b)
Definition: matrix2d.h:170
#define YY(v)
Definition: matrix1d.h:93
#define ZZ(v)
Definition: matrix1d.h:101
double radius
Cone base radius.
Definition: phantom.h:1248
#define SPEED_UP_temps012
Definition: xmipp_macros.h:403

◆ prepare()

void Cone::prepare ( )
virtual

Prepare cone 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 83 of file phantom.cpp.

84 {
85  prepare_Euler();
87 }
void sqrt(Image< double > &op)
double height
Cone height.
Definition: phantom.h:1251
double max_distance
Definition: phantom.h:126
void prepare_Euler()
Definition: phantom.cpp:102
double radius
Cone base radius.
Definition: phantom.h:1248

◆ read_specific() [1/2]

void Cone::read_specific ( char *  line)

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

Definition at line 382 of file phantom.cpp.

383 {
384  int stat;
385  stat = sscanf(line, "%*s %*c %*f %*f %*f %*f %lf %lf %lf %lf %lf", &radius, &height,
386  &rot, &tilt, &psi);
387  if (stat != 5)
388  REPORT_ERROR(ERR_IO_NOREAD, (std::string)"Error when reading a cone" + line);
389  prepare();
390 }
void prepare()
Definition: phantom.cpp:83
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double tilt
Second Euler angle.
Definition: phantom.h:430
double height
Cone height.
Definition: phantom.h:1251
Couldn&#39;t read from file.
Definition: xmipp_error.h:139
double rot
First Euler angle.
Definition: phantom.h:427
double psi
Third Euler angle.
Definition: phantom.h:433
double radius
Cone base radius.
Definition: phantom.h:1248

◆ read_specific() [2/2]

void Cone::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 393 of file phantom.cpp.

394 {
395  if (vect.size() != 5)
396  REPORT_ERROR(ERR_IO_NOREAD, (std::string)"Error when reading a cone");
397  radius = vect[0];
398  height = vect[1];
399  rot = vect[2];
400  tilt = vect[3];
401  psi = vect[4];
402  prepare();
403 }
void prepare()
Definition: phantom.cpp:83
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double tilt
Second Euler angle.
Definition: phantom.h:430
double height
Cone height.
Definition: phantom.h:1251
Couldn&#39;t read from file.
Definition: xmipp_error.h:139
double rot
First Euler angle.
Definition: phantom.h:427
double psi
Third Euler angle.
Definition: phantom.h:433
double radius
Cone base radius.
Definition: phantom.h:1248

◆ scale()

void Cone::scale ( double  factor) const
virtual

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

Implements Feature.

Definition at line 1619 of file phantom.cpp.

1620 {
1621  Cone *f;
1622  f = new Cone;
1624  COPY_ANGLES;
1625 
1626  f->radius = factor * radius;
1627  f->height = factor * height;
1628  f->prepare();
1629  return (Feature *)f;
1630 }
Definition: phantom.h:1244
void prepare()
Definition: phantom.cpp:83
#define COPY_COMMON_PART
Definition: phantom.cpp:1473
double * f
double height
Cone height.
Definition: phantom.h:1251
#define COPY_ANGLES
Definition: phantom.cpp:1479
double radius
Cone base radius.
Definition: phantom.h:1248

◆ volume()

double Cone::volume ( ) const
inlinevirtual

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

Implements Feature.

Definition at line 1295 of file phantom.h.

1296  {
1297  return 1 / 3*PI*radius*radius*height;
1298  }
double height
Cone height.
Definition: phantom.h:1251
#define PI
Definition: tools.h:43
double radius
Cone base radius.
Definition: phantom.h:1248

Friends And Related Function Documentation

◆ operator<<

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

671 {
672  o << " Radius: " << f.radius << std::endl;
673  o << " Height: " << f.height << std::endl;
674  o << " Rot: " << f.rot << std::endl;
675  o << " Tilt: " << f.tilt << std::endl;
676  o << " Psi: " << f.psi << std::endl;
677  return o;
678 }
double tilt
Second Euler angle.
Definition: phantom.h:430
double height
Cone height.
Definition: phantom.h:1251
double rot
First Euler angle.
Definition: phantom.h:427
double psi
Third Euler angle.
Definition: phantom.h:433
double radius
Cone base radius.
Definition: phantom.h:1248

Member Data Documentation

◆ const

Feature** _f Cone::const

Definition at line 1283 of file phantom.h.

◆ height

double Cone::height

Cone height.

Definition at line 1251 of file phantom.h.

◆ radius

double Cone::radius

Cone base radius.

Definition at line 1248 of file phantom.h.


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