Xmipp
v3.23.11-Nereus
|
#include <grids.h>
Public Member Functions | |
SimpleGrid () | |
void | assign (const SimpleGrid &SG) |
void | set_X (const Matrix1D< double > &v) |
void | set_Y (const Matrix1D< double > &v) |
void | set_Z (const Matrix1D< double > &v) |
void | get_X (Matrix1D< double > &v) const |
void | get_Y (Matrix1D< double > &v) const |
void | get_Z (Matrix1D< double > &v) const |
void | getSize (int &Zdim, int &Ydim, int &Xdim) const |
int | get_number_of_samples () const |
void | set_interest_radius (double _R) |
Set reconstruction radius. More... | |
double | get_interest_radius () const |
Get reconstruction radius. More... | |
void | set_relative_size (double size) |
Set relative_size. More... | |
double | get_relative_size () const |
Get relative_size. More... | |
void | prepare_grid () |
void | grid2universe (const Matrix1D< double > &gv, Matrix1D< double > &uv) const |
void | universe2grid (const Matrix1D< double > &uv, Matrix1D< double > &gv) const |
bool | is_interesting (const Matrix1D< double > &uv) const |
void | Gproject_to_plane (const Matrix1D< double > &gr, double rot, double tilt, double psi, Matrix1D< double > &result) const |
void | Gproject_to_plane (const Matrix1D< double > &gr, const Matrix2D< double > &euler, Matrix1D< double > &result) const |
void | Gdir_project_to_plane (const Matrix1D< double > &gr, double rot, double tilt, double psi, Matrix1D< double > &result) const |
void | Gdir_project_to_plane (const Matrix1D< double > &gr, const Matrix2D< double > &euler, Matrix1D< double > &result) const |
Public Attributes | |
Matrix2D< double > | basis |
Matrix2D< double > | inv_basis |
Matrix1D< double > | lowest |
Matrix1D< double > | highest |
double | relative_size |
Measuring unit in the grid coordinate system. More... | |
Matrix1D< double > | origin |
Origin of the grid in the Universal coordinate system. More... | |
double | R2 |
Friends | |
std::ostream & | operator<< (std::ostream &o, const SimpleGrid &grid) |
Basic grid class. A Simple grid is defined as a set of 3 directions (X,Y,Z) which need not to coincide with the universal X,Y,Z (ie, e1, e2, e3), an origin, a relative size to the voxels in the universal grid, and the lowest and highest indexes within the grid (these two last parameters set the grid size and the space where the grid is defined). There will be volume elements at each point of the grid.
The concept of a simple grid is the following: you are defining a coordinate system (translated, rotated and whatever you like with respect to the Universal Coordinate System, and inside this system you must define a "measuring unit". This coordinate system will be valid only in a "box" of the space. A "box" is quoted as because it is a parallelepiped defined by this coordinate system axes, and not by the Universal axes.
So to define the simple grid you must address the following topics:
Coordinate system: The coordinate system is defined by three R3 vectors, called X, Y and Z. They must form a true three dimensional coordinate system, ie, must not be linearly dependent, but they are not restricted to be orthogonal, normal, or whatever. You can specify any R3 vectors with the only condition that the range of the matrix formed by the 3 is not 0.
When a basis function is placed at position (-1,1,2) in the grid coordinate system, it is really placed at (-X+Y+2Z)+origin in the universal coordinate system (these X,Y,Z are the grid axis vectors and must not be confused with the e1(=x), e2(=y), and e3(=z) of the Universal Coordinate System). This is true only if the measuring unit is 1, see the Measuring unit section to know exactly where the samples is placed in space.
The origin of the grid is the position in the Universal coordinate system of the (0,0,0) sample inside the grid, ie, where is the grid sample (0,0,0) in the universal coordinate system?
Measuring unit: The measuring unit is the distance between two samples in the grid lattice, and in the direction of the grid axes. Suppose we have a sample at position (-1,1,2) but the measuring unit instead of being 1 is 2. Then the sample really is at 2(-X+Y+2Z)+origin in the Universal Coordinate System.
This measuring unit is controlled in the class by the public variable relative_size .
This is the default grid after creation:
It should be convenient that you modify these parameters at your convenience. And after setting them PREPARE!! the grid to be used with the function SimpleGrid::prepare_grid . There are several public variables which you might directly modify, namely, origin , relative_size , lowest , and highest .
SimpleGrid::SimpleGrid | ( | ) |
Default constructor. Be careful that this is not an empty constructor as usual but it sets a grid by default (see the class documentation to see exactly which grid is). \ Ex: SimpleGrid sg;
Definition at line 35 of file grids.cpp.
void SimpleGrid::assign | ( | const SimpleGrid & | SG | ) |
|
inline |
Project a grid direction onto a plane (Euler angles). More or less this function goes in the fashion of the preceding ones of projecting a vector. The difference between them is while in the first one the grid vector is translated directly to the universal coordinate system (it is like a point translation, this point in the grid system is this other one in the universal system), in this second function only the direction is translated into the universal coordinate system. Ie, a point in the grid indicates a direction in the grid system, then this same direction is expressed in the universal coordinate system. And then this direction is projected onto the given plane. See Uproject_to_plane for more information about the projection process.
The direction can be seen then as the free vector associated to a given vector in the grid. It can also be seen as the translation to the universal coordinate system of the grid vector when the grid origin is moved to the Universe origin. A pseudocode to get the direction of a given grid vector (gr) is the following
This function can be used, for instance, to compute the projections of the grid axes onto the projection plane.
Definition at line 432 of file grids.h.
|
inline |
Project a grid direction onto a plane (Euler angles). This function does the same as the preceding one, but it accepts an Euler matrix, this might help you to save time when making the projection of a whole volume. See Uproject_to_plane for more information about the projecting process.
Definition at line 446 of file grids.h.
|
inline |
int SimpleGrid::get_number_of_samples | ( | ) | const |
Get number of samples. This function returns the number of samples within the grid. If the grid has a radius of interest, then only those samples within that radius are accounted.
Definition at line 69 of file grids.cpp.
|
inline |
Get relative_size.
Definition at line 283 of file grids.h.
|
inline |
Get X vector of the grid. \Ex: Matrix1D<double> X; sg.get_X(X) << std::endl;
Definition at line 212 of file grids.h.
|
inline |
Get Y vector of the grid. \Ex: Matrix1D<double> Y; sg.get_Y(Y) << std::endl;
Definition at line 219 of file grids.h.
|
inline |
Get Z vector of the grid. \Ex: Matrix1D<double> Z; sg.get_Z(Z) << std::endl;
Definition at line 226 of file grids.h.
|
inline |
Get grid number of samples in each direction. This function returns the number of samples on each direction, this number of samples can be used to resize a volume which might hold a grid like this one. The number of samples is computed as highest-lowest+1. \ Ex: Build a volume able to hold this grid
Definition at line 245 of file grids.h.
|
inline |
Project a grid vector onto a plane (Euler angles). This function projects a vector defined in the Grid coordinate system onto a plane defined by its three Euler angles (measured with respect to the universal coordinate system). This plane is restricted to pass through the Universe origin. This function is used to produce the projection of a volume according to a certain direction (the 3 Euler angles in the universal system). Notice that this function only tells you where a given point in the volume is projecting, but it doesn't tell you the value. See Uproject_to_plane for more information. \ Ex: Matrix1D<double> up=sg.Gproject_to_plane(vectorR3(1,0,0),45,45,60);
Definition at line 381 of file grids.h.
|
inline |
Project a grid vector onto a plane (Euler matrix). This function does the same as the preceding one, but it accepts an Euler matrix, this might help you to save time when making the projection of a whole volume. See Uproject_to_plane for more information. \ Ex:
Definition at line 399 of file grids.h.
|
inline |
Grid –> Universe. This function transforms a vector in the grid coordinate system to the universal one. For example the sample at grid coordinate (-1,2,1) is translated to its position in the universe. Notice that usually this operation is performed with "integer" grid vectors giving "float" universal vectors. The operation performed exactly is
or what is the same:
\Ex: Matrix1D<double> uv; sg.grid2universe(vectorR3(-1,2,1),uv);
Definition at line 318 of file grids.h.
|
inline |
void SimpleGrid::prepare_grid | ( | ) |
Prepare grid for work. This function MUST BE CALLED before working with a simple grid which is not the default one. What it actually does is to check that the grid vectors form a true 3D coordinate system (if not it throws an exception), and if it is calculate the pass matrices from the grid to the universal system (called basis) and viceversa (called inv_basis). \ Ex:
Definition at line 103 of file grids.cpp.
|
inline |
|
inline |
Set relative_size.
Definition at line 277 of file grids.h.
|
inline |
Set X vector of the grid. \Ex: Matrix1D<double> X=vectorR3(1,0,0); sg.set_X(X);
Definition at line 191 of file grids.h.
|
inline |
Set Y vector of the grid. \Ex: Matrix1D<double> Y=vectorR3(0,1,0); sg.set_Y(Y);
Definition at line 198 of file grids.h.
|
inline |
Set Z vector of the grid. \Ex: Matrix1D<double> Z=vectorR3(1,1,1); sg.set_Z(Z);
Definition at line 205 of file grids.h.
|
inline |
Universe –> Grid. This function transforms a vector in the universal coordinate system to the one of the grid. Ie, it gives the position in the grid system of a point in the universe. Notice that this time the position in the grid needs not to be "integer".
The operation performed is
where inv_basis is an internal matrix which contains information about the X, Y and Z vectors. In fact is the inverse of the matrix formed by X, Y and Z. See grid2universe .
Next example should give (0,0,0) as result. \Ex:
Definition at line 349 of file grids.h.
|
friend |
Show a Simple grid. Shows all information about the simple grid. \Ex: std::cout << sg;
Definition at line 47 of file grids.cpp.
Matrix1D<double> SimpleGrid::highest |
Matrix1D<double> SimpleGrid::lowest |
Matrix1D<double> SimpleGrid::origin |
double SimpleGrid::R2 |
double SimpleGrid::relative_size |