本文整理汇总了C++中Matrix_3x3::Zero方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix_3x3::Zero方法的具体用法?C++ Matrix_3x3::Zero怎么用?C++ Matrix_3x3::Zero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix_3x3
的用法示例。
在下文中一共展示了Matrix_3x3::Zero方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToRecip
/** Use box coordinates to calculate unit cell and fractional matrix for use
* with imaging routines. Return cell volume.
*/
double Box::ToRecip(Matrix_3x3& ucell, Matrix_3x3& recip) const {
double u12x,u12y,u12z;
double u23x,u23y,u23z;
double u31x,u31y,u31z;
double volume,onevolume;
// If box lengths are zero no imaging possible
if (box_[0]==0.0 || box_[1]==0.0 || box_[2]==0.0) {
ucell.Zero();
recip.Zero();
return -1.0;
}
ucell[0] = box_[0]; // u(1,1)
ucell[1] = 0.0; // u(2,1)
ucell[2] = 0.0; // u(3,1)
ucell[3] = box_[1]*cos(Constants::DEGRAD*box_[5]); // u(1,2)
ucell[4] = box_[1]*sin(Constants::DEGRAD*box_[5]); // u(2,2)
ucell[5] = 0.0; // u(3,2)
ucell[6] = box_[2]*cos(Constants::DEGRAD*box_[4]);
ucell[7] = (box_[1]*box_[2]*cos(Constants::DEGRAD*box_[3]) - ucell[6]*ucell[3]) / ucell[4];
ucell[8] = sqrt(box_[2]*box_[2] - ucell[6]*ucell[6] - ucell[7]*ucell[7]);
// Get reciprocal vectors
u23x = ucell[4]*ucell[8] - ucell[5]*ucell[7];
u23y = ucell[5]*ucell[6] - ucell[3]*ucell[8];
u23z = ucell[3]*ucell[7] - ucell[4]*ucell[6];
u31x = ucell[7]*ucell[2] - ucell[8]*ucell[1];
u31y = ucell[8]*ucell[0] - ucell[6]*ucell[2];
u31z = ucell[6]*ucell[1] - ucell[7]*ucell[0];
u12x = ucell[1]*ucell[5] - ucell[2]*ucell[4];
u12y = ucell[2]*ucell[3] - ucell[0]*ucell[5];
u12z = ucell[0]*ucell[4] - ucell[1]*ucell[3];
volume=ucell[0]*u23x + ucell[1]*u23y + ucell[2]*u23z;
onevolume = 1.0 / volume;
recip[0] = u23x*onevolume;
recip[1] = u23y*onevolume;
recip[2] = u23z*onevolume;
recip[3] = u31x*onevolume;
recip[4] = u31y*onevolume;
recip[5] = u31z*onevolume;
recip[6] = u12x*onevolume;
recip[7] = u12y*onevolume;
recip[8] = u12z*onevolume;
return volume;
}