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

#include <phantom.h>

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

Public Member Functions

void prepare ()
 
void assign (const Sphere &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 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)
 
- Public Member Functions inherited from Feature
void assign (const Feature &F)
 
virtual void rotate (const Matrix2D< double > &E)
 
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
 Sphere radius. More...
 
Feature **_f const
 
- 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 Sphere &f)
 

Detailed Description

Spheres. The spheres are defined by its center and a radius. The label is "sph".

A point (r) in the universal coordinate system, where spheres are defined in general, can be expressed (rp) with respect to a system where the sphere is centered at the origin and its radius is unity by

V3_MINUS_V3(rp,r,sph.Center);
V3_BY_CT(rp, rp, 1/radius);

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

Definition at line 467 of file phantom.h.

Member Function Documentation

◆ __attribute__()

Sphere::__attribute__ ( (deprecated)  )

Another function for return a scaled sphere.

◆ assign()

void Sphere::assign ( const Sphere F)

Another function for assignment.

Definition at line 108 of file phantom.cpp.

109 {
110  *this = F;
111 }

◆ density_inside()

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

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

Implements Feature.

Definition at line 488 of file phantom.h.

489  {
490  return 1.;
491  }

◆ feat_printf()

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

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

Implements Feature.

Definition at line 405 of file phantom.cpp.

406 {
407  fprintf(fh, "sph %c %1.4f % 7.2f % 7.2f % 7.2f % 7.2f\n",
409  radius);
410 }
double radius
Sphere radius.
Definition: phantom.h:471
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
#define YY(v)
Definition: matrix1d.h:93
fprintf(glob_prnt.io, "\)
#define ZZ(v)
Definition: matrix1d.h:101

◆ feat_printm()

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

Implements Feature.

Definition at line 413 of file phantom.cpp.

414 {
415  std::vector<double> FSVect;
416  FSVect.push_back(radius);
417  MD.setValue(MDL_PHANTOM_FEATURE_SPECIFIC,FSVect, id);
418 }
double radius
Sphere radius.
Definition: phantom.h:471
Specific parameters for a feature (vector double)
bool setValue(const MDLabel label, const T &valueIn, size_t id)

◆ init_rnd()

void Sphere::init_rnd ( double  minradius,
double  maxradius,
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 
)

Generate a random sphere. A sphere 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 1681 of file phantom.cpp.

1687 {
1689  center.resize(3);
1690  type = "sph";
1691  add_assign = '+';
1692  density = rnd_unif(minden, maxden);
1693  XX(center) = rnd_unif(minx0, maxx0);
1694  YY(center) = rnd_unif(miny0, maxy0);
1695  ZZ(center) = rnd_unif(minz0, maxz0);
1696 
1697  radius = rnd_unif(minradius, maxradius);
1698 
1699  max_distance = radius;
1700 }
double radius
Sphere radius.
Definition: phantom.h:471
Matrix1D< double > center
Definition: phantom.h:119
double density
Definition: phantom.h:114
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 max_distance
Definition: phantom.h:126
#define YY(v)
Definition: matrix1d.h:93
std::string type
Definition: phantom.h:101
unsigned int randomize_random_generator()
#define ZZ(v)
Definition: matrix1d.h:101

◆ intersection()

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

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

Implements Feature.

Definition at line 1102 of file phantom.cpp.

1107 {
1108  // This is done in order to correct the different lengths seen by
1109  // rays with different "speed". It is related to the jacobian of
1110  // the transformation from a non-unit direction to a unit one.
1111  double norm = direction.module();
1112 
1113  // Set the passing point in the ellipsoid coordinate system
1114  // and normalise to a unit sphere
1115  V3_MINUS_V3(r, passing_point, center);
1116  V3_BY_CT(r, r, 1 / radius);
1117  V3_BY_CT(u, direction, 1 / radius);
1118  return intersection_unit_sphere(u, r) / norm;
1119 }
double module() const
Definition: matrix1d.h:983
double radius
Sphere radius.
Definition: phantom.h:471
#define V3_MINUS_V3(a, b, c)
Definition: matrix1d.h:202
Matrix1D< double > center
Definition: phantom.h:119
T norm(const std::vector< T > &v)
Definition: vector_ops.h:399
#define V3_BY_CT(a, b, c)
Definition: matrix1d.h:238
double intersection_unit_sphere(const Matrix1D< double > &u, const Matrix1D< double > &r)
Definition: geometry.cpp:1122

◆ point_inside()

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

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

Implements Feature.

Definition at line 695 of file phantom.cpp.

696 {
698 }
#define DEF_Sph_Blob_point_inside
Definition: phantom.cpp:686

◆ prepare()

void Sphere::prepare ( )
virtual

Prepare sphere for work. Computes the maximum distance, in this case, equal to "radius"

Implements Feature.

Definition at line 44 of file phantom.cpp.

45 {
47 }
double radius
Sphere radius.
Definition: phantom.h:471
double max_distance
Definition: phantom.h:126

◆ read_specific() [1/2]

void Sphere::read_specific ( char *  line)

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

Definition at line 222 of file phantom.cpp.

223 {
224  int stat;
225  stat = sscanf(line, "%*s %*c %*f %*f %*f %*f %lf", &radius);
226  if (stat != 1)
227  REPORT_ERROR(ERR_IO_NOREAD, (std::string)"Error when reading a sphere:" + line);
228  prepare();
229 }
double radius
Sphere radius.
Definition: phantom.h:471
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Couldn&#39;t read from file.
Definition: xmipp_error.h:139
void prepare()
Definition: phantom.cpp:44

◆ read_specific() [2/2]

void Sphere::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 231 of file phantom.cpp.

232 {
233  if (vect.size() != 1)
234  REPORT_ERROR(ERR_ARG_MISSING, MDL::label2Str(MDL_PHANTOM_FEATURE_SPECIFIC) + "Error when reading a sphere: empty Feature vector");
235  radius = vect[0];
236  prepare();
237 }
Argument missing.
Definition: xmipp_error.h:114
double radius
Sphere radius.
Definition: phantom.h:471
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Specific parameters for a feature (vector double)
static String label2Str(const MDLabel &label)
void prepare()
Definition: phantom.cpp:44

◆ scale()

void Sphere::scale ( double  factor) const
virtual

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

Implements Feature.

Definition at line 1485 of file phantom.cpp.

1486 {
1487  Sphere *f;
1488  f = new Sphere;
1490 
1491  f->radius = factor * radius;
1492  f->prepare();
1493  return (Feature *)f;
1494 }
double radius
Sphere radius.
Definition: phantom.h:471
#define COPY_COMMON_PART
Definition: phantom.cpp:1473
double * f
void prepare()
Definition: phantom.cpp:44

◆ volume()

double Sphere::volume ( ) const
inlinevirtual

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

Implements Feature.

Definition at line 512 of file phantom.h.

513  {
514  return 4 / 3*PI*radius*radius*radius;
515  }
double radius
Sphere radius.
Definition: phantom.h:471
#define PI
Definition: tools.h:43

Friends And Related Function Documentation

◆ operator<<

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

600 {
601  o << " Radius: " << f.radius << std::endl;
602  return o;
603 }
double radius
Sphere radius.
Definition: phantom.h:471

Member Data Documentation

◆ const

Feature** _f Sphere::const

Definition at line 500 of file phantom.h.

◆ radius

double Sphere::radius

Sphere radius.

Definition at line 471 of file phantom.h.


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