Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
LatticePlaneBase.cpp
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MODEL is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_LatticePlaneBase_cpp_
9#define model_LatticePlaneBase_cpp_
10
11#include <map>
12#include <LatticeModule.h>
13#include <LatticePlaneBase.h>
14
15namespace model
16{
17
19 /* init base */ ReciprocalLatticeDirectionType(v1_in.cross(v2_in)),
20 /* init */ primitiveVectors(std::make_pair(v1_in,v2_in))
21 {
22 assert(primitiveVectors.first.squaredNorm()>0);
23 assert(primitiveVectors.second.squaredNorm()>0);
24 assert(primitiveVectors.first.cross(primitiveVectors.second).squaredNorm()>0);
25 }
26
27 /**********************************************************************/
28 typename LatticePlaneBase::LatticeVectorType LatticePlaneBase::snapToLattice(const Eigen::Matrix<double, 3, 1> &P) const
29 {
30 const Eigen::Matrix<double, 3, 2> B((Eigen::Matrix<double, 2, 3>() << primitiveVectors.first.cartesian().transpose(), primitiveVectors.second.cartesian().transpose()).finished().transpose());
31 const Eigen::Matrix<double, 2, 1> nd = (B.transpose() * B).inverse() * B.transpose() * P;
32 // const Eigen::Matrix<double,3,1> p=B*RoundEigen<double,2>::round(nd);
33 const Eigen::Matrix<double, 3, 1> p = B * nd.array().round().matrix();
34 // return LatticeVectorType(p,primitiveVectors.first.covBasis,primitiveVectors.second.contraBasis);
35 return LatticeVectorType(p, primitiveVectors.first.lattice);
36 }
37
38 /**********************************************************************/
39 typename LatticePlaneBase::VectorDimD LatticePlaneBase::snapToPlane(const Eigen::Matrix<double, 3, 1> &P) const
40 {
41 // return LatticeVectorType(p,primitiveVectors.first.covBasis,primitiveVectors.second.contraBasis);
42 VectorDimD cn(this->cartesian());
43 const double cnNorm(cn.norm());
44 assert(cnNorm > FLT_EPSILON);
45 cn /= cnNorm;
46 return P - P.dot(cn) * cn;
47 }
48
49} // end namespace
50#endif
LatticeDirectionType cross(const ReciprocalLatticeVectorType &other) const
initial point of the source segment B
LatticePlaneBase(const LatticeVectorType &v1_in, const LatticeVectorType &v2_in)
LatticeVectorType snapToLattice(const Eigen::Matrix< double, 3, 1 > &P) const
Eigen::Matrix< double, 3, 1 > VectorDimD
LatticeVector< 3 > LatticeVectorType
const std::pair< LatticeDirectionType, LatticeDirectionType > primitiveVectors
VectorDimD snapToPlane(const Eigen::Matrix< double, 3, 1 > &P) const
ReciprocalLatticeDirection< 3 > ReciprocalLatticeDirectionType
vertex p[3]