Bsoft object

struct UnitCell

Source:

include/UnitCell.h

Description:

Unit cell parameters.

Features:

The convention is as follows:
a lies on the x-axis,
b lies in the x,y plane.

Code:

class UnitCell {
private:
double data[6];
public:
UnitCell() { for ( int i=0; i<3; i++ ) data[i] = 0; for ( int i=3; i<6; i++ ) data[i] = M_PI_2; }
UnitCell(double a, double b, double c, double alf, double bet, double gam) {
data[0] = a; data[1] = b; data[2] = c;
data[3] = alf; data[4] = bet; data[5] = gam;
}
double& operator[](int i) { if ( i < 0 ) i = 0; if ( i > 5 ) i = 5; return data[i]; }
bool check() { double e=1; for ( int i=0; i<6; i++ ) e *= data[i]; return e > 0; }
void a(double d) { data[0] = d; }
void b(double d) { data[1] = d; }
void c(double d) { data[2] = d; }
void alpha(double d) { data[3] = d; }
void beta(double d) { data[4] = d; }
void gamma(double d) { data[5] = d; }
double a() { return data[0]; }
double b() { return data[1]; }
double c() { return data[2]; }
double alpha() { return data[3]; }
double beta() { return data[4]; }
double gamma() { return data[5]; }
void set_angle_range() {
for ( int i=3; i<6; i++ ) {
while ( data[i] < -M_PI ) data[i] += TWOPI;
while ( data[i] > M_PI ) data[i] -= TWOPI;
}
}
void degrees_to_radians() { for ( int i=3; i<6; i++ ) data[i] *= M_PI/180.0; }
void radians_to_degrees() { for ( int i=3; i<6; i++ ) data[i] *= 180.0/M_PI; }
double volume() { return data[0]*data[1]*data[2]*(1 - cos(data[3])*cos(data[3])
- cos(data[4])*cos(data[4]) - cos(data[5])*cos(data[5])
+ 2*cos(data[3])*cos(data[4])*cos(data[5])); }
} ;


Generated by bdoc.pl on Wed May 9 11:41:56 2012


Back to the Bsoft home