 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
33 for (
size_t i = 0; i<3; i++ )
if ( fabs(v[i]) <
TRIGPRECISION ) v[i] = 0;
42 View(vector<double>& vec) :
next(NULL), v(vec), a(0) {
44 if ( vec.size() > 3 ) a = vec[3];
46 View(
const double x,
const double y,
const double z,
const double angle)
52 double ang = atan2(q[3], q[0]);
53 double ca = cos(ang), sa = sin(ang);
54 double q2 = q[0]*q[0] + q[3]*q[3];
55 double f2 = 2*sqrt(q2);
56 if ( q2 <
SMALLFLOAT ) ang = atan2(q[1], q[2]);
57 v[0] = f2*(q[2]*ca + q[1]*sa);
58 v[1] = f2*(q[2]*sa - q[1]*ca);
68 v(-sin(axis)*sin(tilt), cos(axis)*sin(tilt),
78 v = view.v; a = view.a;
83 for ( i=0; i<3 && i<vec.size(); ++i ) v[i] = vec[i];
84 if ( i < vec.size() ) a = vec[i];
88 View vn(-v[0], -v[1], -v[2], -a);
92 return ( v == view.v ) && ( a == view.a );
94 double&
operator[](
size_t i) {
if ( i < 3 )
return v[i];
return a; }
95 double x() {
return v[0]; }
96 double y() {
return v[1]; }
97 double z() {
return v[2]; }
99 void x(
const double d) { v[0] = d; }
100 void y(
const double d) { v[1] = d; }
101 void z(
const double d) { v[2] = d; }
102 void angle(
const double d) { a = d; }
104 return {v[0], v[1], v[2], a};
111 if ( size <
SMALLFLOAT ) { v[0] = v[1] = 0; v[2] = 1; size = 1; }
112 else { v[0] /= size; v[1] /= size; v[2] /= size; }
122 backview.v[0] = -v[0]*ca - v[1]*sa;
123 backview.v[1] = v[0]*sa - v[1]*ca;
124 backview.v[2] = v[2];
133 double ca = cos(ang), sa = sin(ang);
134 double z1 = v[2] + 1, f1, f2;
144 f2 = sqrt(1.0/(2*z1));
146 q[1] = f2*(v[0]*sa - v[1]*ca);
147 q[2] = f2*(v[0]*ca + v[1]*sa);
159 double d = a - view.a;
160 return sqrt((v - view.v).length2() + d*d);
163 double d(v.
scalar(view.v));
164 if ( d < 1 && d > -1 )
return acos(d);
165 else if ( d < 0 )
return M_PI;
169 double d = 1 - cos(a - view.a);
170 return sqrt((v - view.v).length2() + d*d)/2;
181 View*
tilt_views(
double ang_min,
double ang_max,
double ang_step,
double axis);
187 double alpha_step,
double view_angle_limit,
double alpha_angle_limit);
190 double alpha_step3,
double max_alpha3);
int view_list_subset(View **view_list, int start, int size)
Replaces a view list with a subset of it.
View * views_for_refinement(View theview, double alpha_step)
Generates a 3x3 grid of views around an input view.
double distance(const View &view)
View operator=(const View &view)
double & operator[](size_t i)
void angle(const double d)
View * random_views(int nviews)
Calculates a set of random views.
Header file for functions for creating random images.
3x3 Matrix manipulation functions
View(vector< double > &vec)
double scalar(const Vector3 &v) const
View * view_array(View *views, long &n)
Copies views from a list into an array.
double angle_set_negPI_to_PI(double angle)
Returns an angle between -PI and PI.
View * view_list_expand_angles(View *views, double amin, double amax, double astep)
Expands each view to several views with different rotation angles.
double angle(const View &view)
Class for 3-value vectors.
ostream & operator<<(ostream &output, View v)
View(const double x, const double y, const double z, const double angle)
View * views_within_limits(View theview, double theta_step, double phi_step, double alpha_step, double view_angle_limit, double alpha_angle_limit)
Generates a list of views within an angular distance from the input view.
View(double tilt, double axis)
Header file for general utilities.
Vector3< double > vector3()
View random_view()
Calculates a random view.
View(Vector3< double > &vec)
View * tilt_views(double ang_min, double ang_max, double ang_step, double axis)
Initializes a set of views tilted around the y axis.
View(double angle, Vector3< double > axis)
double residual(const View &view)
bool operator==(const View &view)
View view_random_reslice()
Generates a random reslicing 3x3 rotation matrix.
int show_views(View *v)
Displays a linked list of views.
double random_view_error(View &v, double std)
Calculates a new view with a random error from the given view.
View operator=(const vector< double > &vec)
Quaternion quaternion() const