00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef CLIPPER_COORDS
00046 #define CLIPPER_COORDS
00047
00048
00049 #include "cell.h"
00050 #include "spacegroup.h"
00051 #include "clipper_stats.h"
00052
00053
00054 namespace clipper
00055 {
00056
00057 class Grid; class Grid_sampling; class Grid_range;
00058 class Coord_grid; class Coord_map;
00059 class Coord_reci_frac; class Coord_reci_orth;
00060 class Coord_frac; class Coord_orth;
00061 class U_aniso_frac; class U_aniso_orth;
00062
00063
00065
00068 class Resolution
00069 {
00070 public:
00071 inline Resolution() : resol(0.0) {}
00072 explicit Resolution( const ftype& resol_ );
00073 void init( const ftype& resol_ );
00074 const ftype& limit() const;
00075 ftype invresolsq_limit() const;
00076 bool is_null() const;
00077 private:
00078 ftype resol;
00079 };
00080
00081
00083
00086 class HKL_class
00087 {
00088 public:
00090 inline HKL_class() { epsilon_ = 0; allowed_ = 255; }
00092 HKL_class( const Spacegroup& spgr, const HKL& hkl );
00094 inline ftype epsilon() const { return ftype(epsilon_); }
00096 inline ftype epsilonc() const
00097 { if ( centric() ) return 2.0*ftype(epsilon_);
00098 else return ftype(epsilon_); }
00100 inline ftype allowed() const { return ftype(allowed_) * (Util::pi()/12.0); }
00101 inline bool centric() const { return allowed_ != 255; }
00102 inline bool sys_abs() const { return epsilon_ == 0; }
00103 private:
00104 unsigned char epsilon_, allowed_;
00105 };
00106
00107
00109
00112 class RTop_orth : public RTop<>
00113 {
00114 public:
00116 inline RTop_orth() {}
00118 inline explicit RTop_orth( const RTop<>& o ) : RTop<>( o ) {}
00120 inline explicit RTop_orth( const Mat33<>& r ) : RTop<>( r ) {}
00122 inline RTop_orth( const Mat33<>& r, const Vec3<>& t ) : RTop<>( r, t ) {}
00124 RTop_orth( const std::vector<Coord_orth>& src, const std::vector<Coord_orth>& tgt );
00126 template<class T> RTop_orth( const T& src, const T& tgt );
00128 RTop_frac rtop_frac( const Cell& cell ) const;
00130 RTop_orth inverse() const;
00132 Coord_orth axis_coordinate_near( const Coord_orth& centre ) const;
00134 Coord_orth screw_translation() const;
00136 static RTop_orth identity();
00138 static RTop_orth null();
00139 };
00140
00141
00143 class HKL : public Vec3<int>
00144 {
00145 public:
00146 inline HKL() {}
00147 inline explicit HKL( const Vec3<int>& v ) :
00148 Vec3<int>( v ) {}
00149 inline HKL( const int& h, const int& k, const int& l ) :
00150 Vec3<int>( h, k, l ) {}
00151 inline const int& h() const { return (*this)[0]; }
00152 inline const int& k() const { return (*this)[1]; }
00153 inline const int& l() const { return (*this)[2]; }
00154 inline int& h() { return (*this)[0]; }
00155 inline int& k() { return (*this)[1]; }
00156 inline int& l() { return (*this)[2]; }
00157
00158 inline ftype invresolsq( const Cell& cell ) const;
00160 inline Coord_reci_frac coord_reci_frac() const;
00162 inline Coord_reci_orth coord_reci_orth( const Cell& cell ) const;
00164 inline HKL transform( const Symop& op ) const;
00166 inline HKL transform( const Isymop& op ) const;
00168 inline ftype sym_phase_shift( const Symop& op ) const;
00169 String format() const;
00170 friend inline HKL operator -(const HKL& h1)
00171 { return HKL( -h1.h(), -h1.k(), -h1.l() ); }
00172 friend inline HKL operator +(const HKL& h1, const HKL& h2)
00173 { return HKL( h1.h()+h2.h(), h1.k()+h2.k(), h1.l()+h2.l() ); }
00174 friend inline HKL operator -(const HKL& h1, const HKL& h2)
00175 { return HKL( h1.h()-h2.h(), h1.k()-h2.k(), h1.l()-h2.l() ); }
00176 friend inline HKL operator *(const int& s, const HKL& h1)
00177 { return HKL( s*h1.h(), s*h1.k(), s*h1.l() ); }
00178 friend inline HKL operator *(const Isymop& op, const HKL& h1)
00179 { return HKL( h1 * op.rot() ); }
00180 };
00181
00182
00184 class Coord_reci_orth : public Vec3<>
00185 {
00186 public:
00187 inline Coord_reci_orth() {}
00188 inline explicit Coord_reci_orth( const Vec3<>& v ) :
00189 Vec3<>( v ) {}
00190 inline Coord_reci_orth( const ftype& xs, const ftype& ys, const ftype& zs ) : Vec3<>( xs, ys, zs ) {}
00191 inline const ftype& xs() const { return (*this)[0]; }
00192 inline const ftype& ys() const { return (*this)[1]; }
00193 inline const ftype& zs() const { return (*this)[2]; }
00194
00195 inline ftype invresolsq() const;
00197 inline Coord_reci_frac coord_reci_frac( const Cell& cell ) const;
00199 inline Coord_reci_orth transform( const RTop_orth& op ) const
00200 { return Coord_reci_orth( (*this) * op.rot() ); }
00201 String format() const;
00202 };
00203
00204
00206 class Coord_reci_frac : public Vec3<>
00207 {
00208 public:
00209 inline Coord_reci_frac() {}
00210 inline explicit Coord_reci_frac( const Vec3<>& v ) :
00211 Vec3<>( v ) {}
00212 inline Coord_reci_frac( const ftype& us, const ftype& vs, const ftype& ws ) : Vec3<>( us, vs, ws ) {}
00213
00214 inline Coord_reci_frac( const HKL& hkl ) :
00215 Vec3<>( ftype(hkl[0]), ftype(hkl[1]), ftype(hkl[2]) ) {}
00217 inline HKL hkl() const
00218 { return HKL( Util::intr(us()), Util::intr(vs()), Util::intr(ws()) ); }
00220 inline ftype invresolsq( const Cell& cell ) const;
00221 inline const ftype& us() const { return (*this)[0]; }
00222 inline const ftype& vs() const { return (*this)[1]; }
00223 inline const ftype& ws() const { return (*this)[2]; }
00224
00225 inline Coord_reci_orth coord_reci_orth( const Cell& cell ) const;
00227 inline Coord_reci_frac transform( const RTop_frac& op ) const
00228 { return Coord_reci_frac( (*this) * op.rot() ); }
00229 String format() const;
00230 };
00231
00232
00234 class Coord_grid : public Vec3<int>
00235 {
00236 public:
00237 inline Coord_grid() {}
00238
00239 inline explicit Coord_grid( const Vec3<int> v ) : Vec3<int>( v ) {}
00241 inline Coord_grid( const int& u, const int& v, const int& w ) :
00242 Vec3<int>(u,v,w) {}
00244 inline Coord_grid( const Grid& g, const int& index )
00245 { deindex( g, index ); }
00246 inline const int& u() const { return (*this)[0]; }
00247 inline const int& v() const { return (*this)[1]; }
00248 inline const int& w() const { return (*this)[2]; }
00249 inline int& u() { return (*this)[0]; }
00250 inline int& v() { return (*this)[1]; }
00251 inline int& w() { return (*this)[2]; }
00252
00254 inline Coord_map coord_map() const;
00256 inline Coord_frac coord_frac( const Grid_sampling& g ) const;
00258 inline Coord_grid transform( const Isymop& op ) const
00259 { return op * (*this); }
00260
00262 inline Coord_grid unit( const Grid_sampling& g ) const;
00263
00265
00266 inline const Coord_grid& next( const Grid& g );
00268
00269 inline const Coord_grid& next( const Grid_range& g );
00271 inline bool last( const Grid& g ) const;
00273 inline bool last( const Grid_range& g ) const;
00275 inline int index( const Grid& g ) const;
00277 inline void deindex( const Grid& g, const int& index );
00278
00279
00280
00281
00282
00283 String format() const;
00284 friend inline Coord_grid operator -(const Coord_grid& r1)
00285 { return ( Coord_grid( -r1.u(), -r1.v(), -r1.w() ) ); }
00286 friend inline Coord_grid operator +(const Coord_grid& r1, const Coord_grid& r2) { return ( Coord_grid( r1.u()+r2.u(), r1.v()+r2.v(), r1.w()+r2.w() ) ); }
00287 friend inline Coord_grid operator -(const Coord_grid& r1, const Coord_grid& r2) { return ( Coord_grid( r1.u()-r2.u(), r1.v()-r2.v(), r1.w()-r2.w() ) ); }
00288 friend inline Coord_grid operator *(const int& s, const Coord_grid& r1)
00289 { return ( Coord_grid( s*r1.u(), s*r1.v(), s*r1.w() ) ); }
00290 friend inline int operator == (const Coord_grid& r1, const Coord_grid& r2)
00291 { return (r1.u()==r2.u() && r1.v()==r2.v() && r1.w()==r2.w()); }
00292 friend inline int operator != (const Coord_grid& r1, const Coord_grid& r2)
00293 { return (r1.u()!=r2.u() || r1.v()!=r2.v() || r1.w()!=r2.w()); }
00294 friend inline Coord_grid operator *(const Isymop& op, const Coord_grid& r1)
00295 { return Coord_grid( op.rot() * r1 + op.trn() ); }
00296 };
00297
00298
00300 class Coord_orth : public Vec3<>
00301 {
00302 public:
00303 inline Coord_orth() {}
00304 inline explicit Coord_orth( const Vec3<>& v ) :
00305 Vec3<>( v ) {}
00306 inline Coord_orth( const ftype& x, const ftype& y, const ftype& z ) :
00307 Vec3<>( x, y, z ) {}
00308
00309 Coord_orth( const Coord_orth& x1, const Coord_orth& x2, const Coord_orth& x3, const ftype& length, const ftype& angle, const ftype& torsion );
00310 inline const ftype& x() const { return (*this)[0]; }
00311 inline const ftype& y() const { return (*this)[1]; }
00312 inline const ftype& z() const { return (*this)[2]; }
00313
00314 inline ftype lengthsq() const;
00316 inline Coord_frac coord_frac( const Cell& cell ) const;
00318 inline Coord_orth transform( const RTop_orth& op ) const
00319 { return op*(*this); }
00320 String format() const;
00321
00322 static ftype length( const Coord_orth& x1, const Coord_orth& x2);
00324 static ftype angle( const Coord_orth& x1, const Coord_orth& x2,
00325 const Coord_orth& x3);
00327 static ftype torsion( const Coord_orth& x1, const Coord_orth& x2,
00328 const Coord_orth& x3, const Coord_orth& x4);
00329 friend inline Coord_orth operator -(const Coord_orth& x1)
00330 { return Coord_orth( -x1.x(), -x1.y(), -x1.z() ); }
00331 friend inline Coord_orth operator +(const Coord_orth& x1, const Coord_orth& x2) { return Coord_orth( x1.x()+x2.x(), x1.y()+x2.y(), x1.z()+x2.z() ); }
00332 friend inline Coord_orth operator -(const Coord_orth& x1, const Coord_orth& x2) { return Coord_orth( x1.x()-x2.x(), x1.y()-x2.y(), x1.z()-x2.z() ); }
00333 friend inline Coord_orth operator *(const ftype& s, const Coord_orth& x1)
00334 { return Coord_orth( s*x1.x(), s*x1.y(), s*x1.z() ); }
00335 friend inline Coord_orth operator *(const RTop_orth& op, const Coord_orth& x1) { return Coord_orth( op.rot() * x1 + op.trn() ); }
00336 };
00337
00338
00340 class Coord_frac : public Vec3<>
00341 {
00342 public:
00343 inline Coord_frac() {}
00344 inline explicit Coord_frac( const Vec3<>& v ) :
00345 Vec3<>( v ) {}
00346 inline Coord_frac( const ftype& u, const ftype& v, const ftype& w ) :
00347 Vec3<>( u, v, w ) {}
00348 inline const ftype& u() const { return (*this)[0]; }
00349 inline const ftype& v() const { return (*this)[1]; }
00350 inline const ftype& w() const { return (*this)[2]; }
00351
00352 inline ftype lengthsq( const Cell& cell ) const;
00354 inline Coord_orth coord_orth( const Cell& cell ) const;
00356 inline Coord_map coord_map( const Grid& g ) const;
00358 inline Coord_grid coord_grid( const Grid& g ) const;
00360 inline Coord_frac transform( const RTop_frac& op ) const
00361 { return op*(*this); }
00363 inline Coord_frac lattice_copy_zero() const
00364 { return Coord_frac(u()-rint(u()),v()-rint(v()),w()-rint(w())); }
00366 inline Coord_frac lattice_copy_unit() const
00367 { return Coord_frac(u()-floor(u()),v()-floor(v()),w()-floor(w())); }
00369 inline Coord_frac lattice_copy_near(const Coord_frac& n) const
00370 { return (*this-n).lattice_copy_zero()+n; }
00372 Coord_frac symmetry_copy_near(const Spacegroup& spgr, const Cell& cell, const Coord_frac& n) const;
00373 String format() const;
00374 friend inline Coord_frac operator -(const Coord_frac& u1)
00375 { return Coord_frac( -u1.u(), -u1.v(), -u1.w() ); }
00376 friend inline Coord_frac operator +(const Coord_frac& u1, const Coord_frac& u2) { return Coord_frac( u1.u()+u2.u(), u1.v()+u2.v(), u1.w()+u2.w() ); }
00377 friend inline Coord_frac operator -(const Coord_frac& u1, const Coord_frac& u2) { return Coord_frac( u1.u()-u2.u(), u1.v()-u2.v(), u1.w()-u2.w() ); }
00378 friend inline Coord_frac operator *(const ftype& s, const Coord_frac& u1)
00379 { return Coord_frac( s*u1.u(), s*u1.v(), s*u1.w() ); }
00380 friend inline Coord_frac operator *(const RTop_frac& op, const Coord_frac& x1) { return Coord_frac( op.rot() * x1 + op.trn() ); }
00381 };
00382
00383
00385 class Coord_map : public Vec3<>
00386 {
00387 public:
00388 inline Coord_map() {}
00389
00390 inline explicit Coord_map( const Vec3<>& v ) :
00391 Vec3<>( v ) {}
00393 inline explicit Coord_map( const Coord_grid& c ) :
00394 Vec3<>( ftype(c[0]), ftype(c[1]), ftype(c[2]) ) {}
00396 inline Coord_map( const ftype& u, const ftype& v, const ftype& w ) :
00397 Vec3<>( u, v, w ) {}
00399 inline Coord_frac coord_frac( const Grid& g ) const;
00401 inline Coord_grid coord_grid() const { return Coord_grid( Util::intr((*this)[0]), Util::intr((*this)[1]), Util::intr((*this)[2]) ); }
00403 inline Coord_grid floor() const { return Coord_grid( Util::intf((*this)[0]), Util::intf((*this)[1]), Util::intf((*this)[2]) ); }
00405 inline Coord_grid ceil() const { return Coord_grid( Util::intc((*this)[0]), Util::intc((*this)[1]), Util::intc((*this)[2]) ); }
00406 inline const ftype& u() const { return (*this)[0]; }
00407 inline const ftype& v() const { return (*this)[1]; }
00408 inline const ftype& w() const { return (*this)[2]; }
00409 String format() const;
00410 friend inline Coord_map operator -(const Coord_map& u1)
00411 { return Coord_map( -u1.u(), -u1.v(), -u1.w() ); }
00412 friend inline Coord_map operator +(const Coord_map& u1, const Coord_map& u2)
00413 { return Coord_map( u1.u()+u2.u(), u1.v()+u2.v(), u1.w()+u2.w() ); }
00414 friend inline Coord_map operator -(const Coord_map& u1, const Coord_map& u2)
00415 { return Coord_map( u1.u()-u2.u(), u1.v()-u2.v(), u1.w()-u2.w() ); }
00416 friend inline Coord_map operator *(const ftype& s, const Coord_map& u1)
00417 { return Coord_map( s*u1.u(), s*u1.v(), s*u1.w() ); }
00418 };
00419
00420
00422
00424 class U_aniso_orth : public Mat33sym<>
00425 {
00426 public:
00428 inline U_aniso_orth() {};
00430 inline explicit U_aniso_orth( const Mat33sym<>& m ) : Mat33sym<>(m) {}
00432 inline explicit U_aniso_orth( const ftype& u ) :
00433 Mat33sym<>( u, u, u, 0.0, 0.0, 0.0 ) {}
00435 U_aniso_orth( const ftype& u11, const ftype& u22, const ftype& u33,
00436 const ftype& u12, const ftype& u13, const ftype& u23 ) :
00437 Mat33sym<>( u11, u22, u33, u12, u13, u23 ) {}
00439 ftype u_iso() const;
00441 U_aniso_frac u_aniso_frac( const Cell& cell ) const;
00443 U_aniso_orth transform( const RTop_orth& op ) const;
00444 friend U_aniso_orth operator +(const U_aniso_orth& u1, const U_aniso_orth& u2) { return U_aniso_orth( u1.mat00()+u2.mat00(), u1.mat11()+u2.mat11(), u1.mat22()+u2.mat22(), u1.mat01()+u2.mat01(), u1.mat02()+u2.mat02(), u1.mat12()+u2.mat12() ); }
00445 friend U_aniso_orth operator -(const U_aniso_orth& u) { return U_aniso_orth( -u.mat00(), -u.mat11(), -u.mat22(), -u.mat01(), -u.mat02(), -u.mat12() ); }
00446 friend U_aniso_orth operator *(const ftype& s, const U_aniso_orth& u) { return U_aniso_orth( s*u.mat00(), s*u.mat11(), s*u.mat22(), s*u.mat01(), s*u.mat02(), s*u.mat12() ); }
00447 };
00448
00449
00451
00453 class U_aniso_frac : public Mat33sym<>
00454 {
00455 public:
00457 inline U_aniso_frac() {};
00459 inline explicit U_aniso_frac( const Mat33sym<>& m ) : Mat33sym<>(m) {}
00461 U_aniso_frac( const ftype& u11, const ftype& u22, const ftype& u33,
00462 const ftype& u12, const ftype& u13, const ftype& u23 ) :
00463 Mat33sym<>( u11, u22, u33, u12, u13, u23 ) {}
00465 U_aniso_orth u_aniso_orth( const Cell& cell ) const;
00467 U_aniso_frac transform( const RTop_frac& op ) const;
00468 friend U_aniso_frac operator +(const U_aniso_frac& u1, const U_aniso_frac& u2) { return U_aniso_frac( u1.mat00()+u2.mat00(), u1.mat11()+u2.mat11(), u1.mat22()+u2.mat22(), u1.mat01()+u2.mat01(), u1.mat02()+u2.mat02(), u1.mat12()+u2.mat12() ); }
00469 friend U_aniso_frac operator -(const U_aniso_frac& u) { return U_aniso_frac( -u.mat00(), -u.mat11(), -u.mat22(), -u.mat01(), -u.mat02(), -u.mat12() ); }
00470 friend U_aniso_frac operator *(const ftype& s, const U_aniso_frac& u) { return U_aniso_frac( s*u.mat00(), s*u.mat11(), s*u.mat22(), s*u.mat01(), s*u.mat02(), s*u.mat12() ); }
00471 };
00472
00473
00475
00477 class Grid : public Vec3<int>
00478 {
00479 public:
00480 inline Grid() {}
00481 inline Grid( const int& nu, const int& nv, const int& nw ) :
00482 Vec3<int>( nu, nv, nw ) {}
00483 inline const int& nu() const { return (*this)[0]; }
00484 inline const int& nv() const { return (*this)[1]; }
00485 inline const int& nw() const { return (*this)[2]; }
00486
00487 inline int size() const { return nu()*nv()*nw(); }
00489 inline bool in_grid( Coord_grid g ) const { return (g.u() >= 0 && g.u() < nu() && g.v() >= 0 && g.v() < nv() && g.w() >= 0 && g.w() < nw()); }
00490
00492 inline int index( const Coord_grid& c ) const { return c.index(*this); }
00494 inline Coord_grid deindex( const int& index ) const { return Coord_grid( *this, index ); }
00495 String format() const;
00496 void debug() const;
00497 };
00498
00499
00501
00513 class Grid_sampling : public Grid
00514 {
00515 public:
00517 inline Grid_sampling() : Grid(Grid(0,0,0)) {}
00519 inline Grid_sampling( const int& nu, const int& nv, const int& nw ) :
00520 Grid( nu, nv, nw ) {}
00522 Grid_sampling( const Spacegroup& spacegroup, const Cell& cell, const Resolution& resol, const ftype rate = 1.5 );
00524 void init( const Spacegroup& spacegroup, const Cell& cell, const Resolution& resol, const ftype rate = 1.5 );
00525
00527 Mat33<> matrix_grid_frac() const;
00529 Mat33<> matrix_frac_grid() const;
00530
00532 bool is_null() const;
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542 };
00543
00544
00546
00550 class HKL_sampling
00551 {
00552 public:
00554 HKL_sampling();
00555
00556 HKL_sampling( const Cell& cell, const Resolution& resolution );
00558 HKL hkl_limit() const;
00560 Resolution resolution( const Cell& cell ) const;
00562 inline bool in_resolution( const HKL& h ) const
00563 { return ( m00*itype64(h.h()*h.h()) + m11*itype64(h.k()*h.k()) +
00564 m22*itype64(h.l()*h.l()) + m01*itype64(h.h()*h.k()) +
00565 m02*itype64(h.h()*h.l()) + m12*itype64(h.k()*h.l()) )
00566 <= ( sqrt_limit_value*sqrt_limit_value ); }
00568 bool is_null() const;
00569 String format() const;
00570 friend inline int operator == (const HKL_sampling& h1, const HKL_sampling& h2)
00571 { return ( h1.m00==h2.m00 && h1.m11==h2.m11 && h1.m22==h2.m22 &&
00572 h1.m01==h2.m01 && h1.m02==h2.m02 && h1.m12==h2.m12 ); }
00573 private:
00574 static itype64 sqrt_limit_value;
00575 itype64 m00, m11, m22, m01, m02, m12;
00576 };
00577
00578
00580
00582 class Grid_range : public Grid
00583 {
00584 public:
00586 inline Grid_range() {}
00588 Grid_range( const Coord_grid& min, const Coord_grid& max );
00590 Grid_range( const Grid& grid, const Coord_frac& min, const Coord_frac& max );
00592 Grid_range( const Cell& cell, const Grid& grid, const ftype& radius );
00594 const Coord_grid& min() const { return min_; }
00596 const Coord_grid& max() const { return max_; }
00598 void add_border( const int b );
00600 bool in_grid( Coord_grid g ) const { return (g.u() >= min_.u() && g.u() <= max_.u() && g.v() >= min_.v() && g.v() <= max_.v() && g.w() >= min_.w() && g.w() <= max_.w()); }
00601
00603 int index( const Coord_grid& c ) const { return (c - min_).index(*this); }
00605 Coord_grid deindex( const int& index ) const { return Coord_grid( *this, index ) + min_; }
00606 private:
00607 Coord_grid min_, max_;
00608 };
00610 typedef Grid_range Grid_map;
00611
00612
00614
00618 class Atom
00619 {
00620 public:
00622 Atom() {}
00624 template<class T> Atom( const T& atom ) : element_(atom.element()), coord_orth_(atom.coord_orth()), u_aniso_orth_(atom.u_aniso_orth()) , occupancy_(atom.occupancy()), u_iso_(atom.u_iso()){}
00626 const String& element() const { return element_; }
00628 const Coord_orth& coord_orth() const { return coord_orth_; }
00630 const ftype& occupancy() const { return occupancy_; }
00632 const ftype& u_iso() const { return u_iso_; }
00634 const U_aniso_orth& u_aniso_orth() const { return u_aniso_orth_; }
00635 void set_element( const String& s );
00636 void set_coord_orth( const Coord_orth& s );
00637 void set_occupancy( const ftype& s );
00638 void set_u_iso( const ftype& s );
00639 void set_u_aniso_orth( const U_aniso_orth& s );
00640
00641 void transform( const RTop_orth rt );
00643 bool is_null() const { return coord_orth_.is_null(); }
00645 static Atom null();
00646 private:
00647 String element_;
00648 Coord_orth coord_orth_;
00649 U_aniso_orth u_aniso_orth_;
00650 ftype occupancy_, u_iso_;
00651 };
00652
00653
00655
00660 class Atom_list : public std::vector<Atom>
00661 {
00662 public:
00664 Atom_list() {}
00666 Atom_list( const std::vector<Atom>& list ) : std::vector<Atom>( list ) {}
00668 template<class T> Atom_list( const T& list ) { for ( int i = 0; i < list.size(); i++ ) push_back( Atom( list[i] ) ); }
00669 };
00670
00671
00672
00673
00681 template<class T> RTop_orth::RTop_orth( const T& src, const T& tgt )
00682 {
00683 std::vector<Coord_orth> vsrc( src.size() );
00684 std::vector<Coord_orth> vtgt( tgt.size() );
00685 for ( int i = 0; i < src.size(); i++ ) vsrc[i] = src[i].coord_orth();
00686 for ( int i = 0; i < tgt.size(); i++ ) vtgt[i] = tgt[i].coord_orth();
00687 (*this) = RTop_orth( vsrc, vtgt );
00688 }
00689
00690
00694 HKL HKL::transform( const Symop& op ) const
00695 { return Coord_reci_frac(*this).transform(op).hkl(); }
00699 HKL HKL::transform( const Isymop& op ) const
00700 { return op*(*this); }
00705 ftype HKL::sym_phase_shift( const Symop& op ) const
00706 { return -Util::twopi()*( Coord_reci_frac(*this) * op.trn() ); }
00707
00711 const Coord_grid& Coord_grid::next( const Grid& g )
00712 { w()++; if ( w() >= g.nw() ) { w() = 0; v()++; if ( v() >= g.nv() ) { v() = 0; u()++; } } return *this; }
00716 const Coord_grid& Coord_grid::next( const Grid_range& g )
00717 { w()++; if ( w() > g.max().w() ) { w() = g.min().w(); v()++; if ( v() > g.max().v() ) { v() = g.min().v(); u()++; } } return *this; }
00721 bool Coord_grid::last( const Grid& g ) const
00722 { return ( u() >= g.nu() ); }
00726 bool Coord_grid::last( const Grid_range& g ) const
00727 { return ( u() > g.max().u() ); }
00732 int Coord_grid::index( const Grid& g ) const
00733 { return ( u()*g.nv() + v() )*g.nw() + w(); }
00738 void Coord_grid::deindex( const Grid& g, const int& index )
00739 { u() = index/(g.nv()*g.nw()); v() = (index/g.nw()) % g.nv(); w() = (index) % g.nw(); }
00740
00742 Coord_grid Coord_grid::unit( const Grid_sampling& g ) const
00743 { return Coord_grid( Util::mod(u(), g.nu()), Util::mod(v(), g.nv()), Util::mod(w(), g.nw()) ); }
00745 Coord_map Coord_grid::coord_map() const
00746 { return Coord_map( *this ); }
00750 Coord_frac Coord_grid::coord_frac( const Grid_sampling& g ) const
00751 { return Coord_frac( ftype(u())/ftype(g.nu()), ftype(v())/ftype(g.nv()), ftype(w())/ftype(g.nw()) ); }
00752
00755 ftype HKL::invresolsq( const Cell& cell ) const
00756 { return cell.metric_reci().lengthsq( Coord_reci_frac( *this ) ); }
00758 Coord_reci_frac HKL::coord_reci_frac() const
00759 { return Coord_reci_frac( *this ); }
00761 Coord_reci_orth HKL::coord_reci_orth( const Cell& cell ) const
00762 { return coord_reci_frac().coord_reci_orth( cell ); }
00764 ftype Coord_reci_orth::invresolsq() const
00765 { return xs()*xs() + ys()*ys() + zs()*zs(); }
00767 Coord_reci_frac Coord_reci_orth::coord_reci_frac( const Cell& cell ) const
00768 { return Coord_reci_frac( (*this) * cell.matrix_orth() ); }
00770 ftype Coord_reci_frac::invresolsq( const Cell& cell ) const
00771 { return cell.metric_reci().lengthsq( *this ); }
00773 Coord_reci_orth Coord_reci_frac::coord_reci_orth( const Cell& cell ) const
00774 { return Coord_reci_orth( (*this) * cell.matrix_frac() ); }
00775
00777 ftype Coord_orth::lengthsq() const
00778 { return x()*x()+y()*y()+z()*z(); }
00780 Coord_frac Coord_orth::coord_frac( const Cell& cell ) const
00781 { return Coord_frac( cell.matrix_frac() * (*this) ); }
00783 ftype Coord_frac::lengthsq( const Cell& cell ) const
00784 { return cell.metric_real().lengthsq( *this ); }
00786 Coord_orth Coord_frac::coord_orth( const Cell& cell ) const
00787 { return Coord_orth( cell.matrix_orth() * (*this) ); }
00789 Coord_map Coord_frac::coord_map( const Grid& g ) const
00790 { return Coord_map( u()*ftype(g.nu()), v()*ftype(g.nv()), w()*ftype(g.nw()) ); }
00792 Coord_grid Coord_frac::coord_grid( const Grid& g ) const
00793 { return Coord_grid( Util::intr(u()*ftype(g.nu())), Util::intr(v()*ftype(g.nv())), Util::intr(w()*ftype(g.nw())) ); }
00795 Coord_frac Coord_map::coord_frac( const Grid& g ) const
00796 { return Coord_frac( u()/ftype(g.nu()), v()/ftype(g.nv()), w()/ftype(g.nw()) ); }
00797
00798 }
00799
00800 #endif