Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
LatticeLine.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_LatticeLine_cpp_
9#define model_LatticeLine_cpp_
10
11#include <LatticeModule.h>
12#include <LatticeLine.h>
13#include <math.h> /* round, floor, ceil, trunc */
14
15namespace model
16{
17
19 /* init */ P(P_in),
20 /* init */ d(d_in)
21 {
22 assert(&P.lattice==&d.lattice && "LatticeVectors have different bases.");
23 }
24
26 {
27 return snapToLattice(P0.cartesian());
28 }
29
31 {
32 const VectorDimD dc(d.cartesian());
33 const VectorDimD Pc(P.cartesian());
34 const double n = (P0 - Pc).dot(dc) / dc.squaredNorm();
35 return P + d * lround(n);
36 }
37
39 {
40 VectorDimD dc(d.cartesian());
41 const VectorDimD Pc(P.cartesian());
42 const double dNorm(dc.norm());
43 assert(dNorm > FLT_EPSILON);
44 dc /= dNorm;
45 return Pc + (P0 - Pc).dot(dc) * dc;
46 }
47
49 {
50 assert(&P.lattice == &P0.lattice && "LatticeVectors have different bases.");
51 return LatticeDirectionType(P0 - P).cross(d).base().squaredNorm() == 0;
52 }
53
54} // end namespace
55#endif
ReciprocalLatticeDirectionType cross(const LatticeVectorType &other) const
const LatticeDirectionType d
Definition LatticeLine.h:24
bool contains(const LatticeVectorType &P0) const
LatticeVectorType snapToLattice(const LatticeVectorType &P0) const
VectorDimD snapToLine(const VectorDimD &P0) const
const LatticeVectorType P
Definition LatticeLine.h:23
LatticeVectorType::VectorDimD VectorDimD
Definition LatticeLine.h:21
LatticeVector< 3 > LatticeVectorType
Definition LatticeLine.h:19
LatticeDirection< 3 > LatticeDirectionType
Definition LatticeLine.h:20
LatticeLine(const LatticeVectorType &P_in, const LatticeVectorType &d_in)