45 #ifndef CLIPPER_COORDS
46 #define CLIPPER_COORDS
50 #include "spacegroup.h"
51 #include "clipper_stats.h"
57 class Grid;
class Grid_sampling;
class Grid_range;
58 class Coord_grid;
class Coord_map;
59 class Coord_reci_frac;
class Coord_reci_orth;
60 class Coord_frac;
class Coord_orth;
61 class U_aniso_frac;
class U_aniso_orth;
90 inline HKL_class() { epsilon_ = 0; allowed_ = 255; }
98 else return ftype(epsilon_); }
101 inline bool centric()
const {
return allowed_ != 255; }
102 inline bool sys_abs()
const {
return epsilon_ == 0; }
104 unsigned char epsilon_, allowed_;
124 RTop_orth(
const std::vector<Coord_orth>& src,
const std::vector<Coord_orth>& tgt );
126 RTop_orth(
const std::vector<Coord_orth>& src,
const std::vector<Coord_orth>& tgt,
const std::vector<ftype>& wgt );
128 template<
class T>
RTop_orth(
const T& src,
const T& tgt );
151 inline HKL(
const int&
h,
const int&
k,
const int&
l ) :
152 Vec3<int>( h, k, l ) {}
153 inline const int&
h()
const {
return (*
this)[0]; }
154 inline const int&
k()
const {
return (*
this)[1]; }
155 inline const int&
l()
const {
return (*
this)[2]; }
156 inline int&
h() {
return (*
this)[0]; }
157 inline int&
k() {
return (*
this)[1]; }
158 inline int&
l() {
return (*
this)[2]; }
172 friend inline HKL operator -(
const HKL& h1)
173 {
return HKL( -h1.
h(), -h1.
k(), -h1.
l() ); }
174 friend inline HKL operator +(
const HKL& h1,
const HKL& h2)
175 {
return HKL( h1.h()+h2.h(), h1.k()+h2.k(), h1.l()+h2.l() ); }
176 friend inline HKL operator -(
const HKL& h1,
const HKL& h2)
177 {
return HKL( h1.h()-h2.h(), h1.k()-h2.k(), h1.l()-h2.l() ); }
178 friend inline HKL operator *(
const int& s,
const HKL& h1)
179 {
return HKL( s*h1.h(), s*h1.k(), s*h1.l() ); }
180 friend inline HKL operator *(
const Isymop& op,
const HKL& h1)
181 {
return HKL( h1 * op.rot() ); }
193 inline const ftype&
xs()
const {
return (*
this)[0]; }
194 inline const ftype&
ys()
const {
return (*
this)[1]; }
195 inline const ftype&
zs()
const {
return (*
this)[2]; }
223 inline const ftype&
us()
const {
return (*
this)[0]; }
224 inline const ftype&
vs()
const {
return (*
this)[1]; }
225 inline const ftype&
ws()
const {
return (*
this)[2]; }
248 inline const int&
u()
const {
return (*
this)[0]; }
249 inline const int&
v()
const {
return (*
this)[1]; }
250 inline const int&
w()
const {
return (*
this)[2]; }
251 inline int&
u() {
return (*
this)[0]; }
252 inline int&
v() {
return (*
this)[1]; }
253 inline int&
w() {
return (*
this)[2]; }
261 {
return op * (*this); }
273 inline bool last(
const Grid& g )
const;
291 {
return (
Coord_grid( s*r1.u(), s*r1.v(), s*r1.w() ) ); }
293 {
return (r1.u()==r2.u() && r1.v()==r2.v() && r1.w()==r2.w()); }
295 {
return (r1.u()!=r2.u() || r1.v()!=r2.v() || r1.w()!=r2.w()); }
297 {
return Coord_grid( op.rot() * r1 + op.trn() ); }
312 inline const ftype&
x()
const {
return (*
this)[0]; }
313 inline const ftype&
y()
const {
return (*
this)[1]; }
314 inline const ftype&
z()
const {
return (*
this)[2]; }
321 {
return op*(*this); }
336 {
return Coord_orth( s*x1.x(), s*x1.y(), s*x1.z() ); }
350 inline const ftype&
u()
const {
return (*
this)[0]; }
351 inline const ftype&
v()
const {
return (*
this)[1]; }
352 inline const ftype&
w()
const {
return (*
this)[2]; }
363 {
return op*(*this); }
381 {
return Coord_frac( s*u1.u(), s*u1.v(), s*u1.w() ); }
408 inline const ftype&
u()
const {
return (*
this)[0]; }
409 inline const ftype&
v()
const {
return (*
this)[1]; }
410 inline const ftype&
w()
const {
return (*
this)[2]; }
415 {
return Coord_map( u1.u()+u2.u(), u1.v()+u2.v(), u1.w()+u2.w() ); }
417 {
return Coord_map( u1.u()-u2.u(), u1.v()-u2.v(), u1.w()-u2.w() ); }
419 {
return Coord_map( s*u1.u(), s*u1.v(), s*u1.w() ); }
435 Mat33sym<>( u, u, u, 0.0, 0.0, 0.0 ) {}
439 Mat33sym<>( u11, u22, u33, u12, u13, u23 ) {}
465 Mat33sym<>( u11, u22, u33, u12, u13, u23 ) {}
484 Vec3<int>( nu, nv, nw ) {}
485 inline const int&
nu()
const {
return (*
this)[0]; }
486 inline const int&
nv()
const {
return (*
this)[1]; }
487 inline const int&
nw()
const {
return (*
this)[2]; }
488 inline int size()
const {
return nu()*
nv()*
nw(); }
522 Grid( nu, nv, nw ) {}
565 {
return ( m00*itype64(h.
h()*h.
h()) + m11*itype64(h.
k()*h.
k()) +
566 m22*itype64(h.
l()*h.
l()) + m01*itype64(h.
h()*h.
k()) +
567 m02*itype64(h.
h()*h.
l()) + m12*itype64(h.
k()*h.
l()) )
568 <= ( sqrt_limit_value*sqrt_limit_value ); }
573 {
return ( h1.m00==h2.m00 && h1.m11==h2.m11 && h1.m22==h2.m22 &&
574 h1.m01==h2.m01 && h1.m02==h2.m02 && h1.m12==h2.m12 ); }
576 static itype64 sqrt_limit_value;
577 itype64 m00, m11, m22, m01, m02, m12;
602 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()); }
652 ftype occupancy_, u_iso_;
670 template<
class T>
Atom_list(
const T& list ) {
for (
int i = 0; i < list.size(); i++ ) push_back(
Atom( list[i] ) ); }
685 std::vector<Coord_orth> vsrc( src.size() );
686 std::vector<Coord_orth> vtgt( tgt.size() );
687 for (
int i = 0; i < src.size(); i++ ) vsrc[i] = src[i].coord_orth();
688 for (
int i = 0; i < tgt.size(); i++ ) vtgt[i] = tgt[i].coord_orth();
702 {
return op*(*this); }
714 {
w()++;
if (
w() >= g.
nw() ) {
w() = 0;
v()++;
if (
v() >= g.
nv() ) {
v() = 0;
u()++; } }
return *
this; }
719 {
w()++;
if (
w() > g.
max().
w() ) {
w() = g.
min().
w();
v()++;
if (
v() > g.
max().
v() ) {
v() = g.
min().
v();
u()++; } }
return *
this; }
724 {
return (
u() >= g.
nu() ); }
729 {
return (
u() > g.
max().
u() ); }
735 {
return (
u()*g.
nv() +
v() )*g.
nw() +
w(); }
741 {
u() = index/(g.
nv()*g.
nw());
v() = (index/g.
nw()) % g.
nv();
w() = (
index) % g.
nw(); }
780 {
return x()*
x()+
y()*
y()+
z()*
z(); }