19 #ifndef GEOM_VECMAT3_OP_HH
20 #define GEOM_VECMAT3_OP_HH
35 return v[0]*v[0]+v[1]*v[1]+v[2]*v[2];
48 return std::fabs(v1[0]-v2[0])<ephilon &&
49 std::fabs(v1[1]-v2[1])<ephilon &&
50 std::fabs(v1[2]-v2[2])<ephilon;
57 return std::fabs(m1(0,0)-m2(0,0))<ephilon &&
58 std::fabs(m1(0,1)-m2(0,1))<ephilon &&
59 std::fabs(m1(0,2)-m2(0,2))<ephilon &&
60 std::fabs(m1(1,0)-m2(1,0))<ephilon &&
61 std::fabs(m1(1,1)-m2(1,1))<ephilon &&
62 std::fabs(m1(1,2)-m2(1,2))<ephilon &&
63 std::fabs(m1(2,0)-m2(2,0))<ephilon &&
64 std::fabs(m1(2,1)-m2(2,1))<ephilon &&
65 std::fabs(m1(2,2)-m2(2,2))<ephilon;
71 return v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2];
87 Vec3 nrvo(v1[1]*v2[2]-v2[1]*v1[2],
88 v1[2]*v2[0]-v2[2]*v1[0],
89 v1[0]*v2[1]-v2[0]*v1[1]);
96 Vec3 nrvo(v1[0]*v2[0],v1[1]*v2[1],v1[2]*v2[2]);
103 Vec3 nrvo(v1[0]/v2[0],v1[1]/v2[1],v1[2]/v2[2]);
110 Vec3 nrvo(v[0]*m(0,0)+v[1]*m(1,0)+v[2]*m(2,0),
111 v[0]*m(0,1)+v[1]*m(1,1)+v[2]*m(2,1),
112 v[0]*m(0,2)+v[1]*m(1,2)+v[2]*m(2,2));
119 Vec3 nrvo(v[0]*m(0,0)+v[1]*m(0,1)+v[2]*m(0,2),
120 v[0]*m(1,0)+v[1]*m(1,1)+v[2]*m(1,2),
121 v[0]*m(2,0)+v[1]*m(2,1)+v[2]*m(2,2));
128 Mat3 nrvo(m1(0,0)*m2(0,0)+m1(0,1)*m2(1,0)+m1(0,2)*m2(2,0),
129 m1(0,0)*m2(0,1)+m1(0,1)*m2(1,1)+m1(0,2)*m2(2,1),
130 m1(0,0)*m2(0,2)+m1(0,1)*m2(1,2)+m1(0,2)*m2(2,2),
132 m1(1,0)*m2(0,0)+m1(1,1)*m2(1,0)+m1(1,2)*m2(2,0),
133 m1(1,0)*m2(0,1)+m1(1,1)*m2(1,1)+m1(1,2)*m2(2,1),
134 m1(1,0)*m2(0,2)+m1(1,1)*m2(1,2)+m1(1,2)*m2(2,2),
136 m1(2,0)*m2(0,0)+m1(2,1)*m2(1,0)+m1(2,2)*m2(2,0),
137 m1(2,0)*m2(0,1)+m1(2,1)*m2(1,1)+m1(2,2)*m2(2,1),
138 m1(2,0)*m2(0,2)+m1(2,1)*m2(1,2)+m1(2,2)*m2(2,2));
172 const Vec3 r1 = p2-p1;
173 const Vec3 r2 = p3-p2;
174 const Vec3 r3 = p4-p3;
177 return std::atan2(
Dot(r1*
Length(r2), r23cross),
Dot(r12cross, r23cross));
183 Vec3 nrvo(std::min(v1[0],v2[0]),
184 std::min(v1[1],v2[1]),
185 std::min(v1[2],v2[2]));
192 Vec3 nrvo(std::max(v1[0],v2[0]),
193 std::max(v1[1],v2[1]),
194 std::max(v1[2],v2[2]));
209 for (
int i=0; i<3; i++) {
210 if (std::fabs(v[i])>ucell_size[i]/2.){
211 v[i]=std::fabs(v[i])-ucell_size[i]*int(std::fabs(v[i])/ucell_size[i]+0.5);
Three dimensional vector class, using Real precision.
#define DLLEXPORT_OST_GEOM
Vec2 CompDivide(const Vec2 &v1, const Vec2 &v2)
divide each component of v1 by that of v2
Real DLLEXPORT_OST_GEOM MinDistanceWithPBC(const Vec3List &l1, const Vec3List &l2, Vec3 &ucell_size)
returns the minimal distance between the points in two Vec3List
Vec3List DLLEXPORT_OST_GEOM WrapVec3List(const Vec3List &vl, const Vec3 &box_center, const Vec3 &ucell_size)
wraps all the vectors in a Vec3List in a box with periodic boundaries
Vec3 Cross(const Vec3 &v1, const Vec3 &v2)
vector cross product
Real DLLEXPORT_OST_GEOM Angle(const Line2 &l1, const Line2 &l2)
Real DLLEXPORT_OST_GEOM Distance(const Line2 &l, const Vec2 &v)
Vec2 Min(const Vec2 &v1, const Vec2 &v2)
Vec2 CompMultiply(const Vec2 &v1, const Vec2 &v2)
multiply each component of v1 with that of v2
Vec2 Max(const Vec2 &v1, const Vec2 &v2)
Quat DLLEXPORT_OST_GEOM Normalize(const Quat &q)
Real DihedralAngle(const Vec3 &p1, const Vec3 &p2, const Vec3 &p3, const Vec3 &p4)
Get dihedral angle for p1-p2-p3-p4.
Real DLLEXPORT_OST_GEOM MinDistance(const Vec3List &l1, const Vec3List &l2)
returns the minimal distance between the points in two Vec3List
Real DistanceWithPBC(const Vec3 &v1, const Vec3 &v2, const Vec3 &ucell_size)
return the distance between two points with periodic boundaries in x,y,z given in ucell_size
Real DLLEXPORT_OST_GEOM Dot(const Quat &q0, const Quat &q1)
std::vector< unsigned int > DLLEXPORT_OST_GEOM MinDistanceIndices(const Vec3List &l1, const Vec3List &l2)
Vec3 DLLEXPORT_OST_GEOM OrthogonalVector(const Vec3 &axis)
get arbitrary vector orthogonal to axis
Vec3 DLLEXPORT_OST_GEOM WrapVec3(const Vec3 &v1, const Vec3 &box_center, const Vec3 &ucell_size)
wraps a vector in a box with periodic boundaries
Mat3 DLLEXPORT_OST_GEOM EulerTransformation(Real theta, Real phi, Real xi)
Real Distance2WithPBC(const Vec3 &v1, const Vec3 &v2, const Vec3 &ucell_size)
return the squared distance between two points with periodic boundaries in x,y,z given in ucell_size
Real DLLEXPORT_OST_GEOM Minor(const Mat3 &m, unsigned int i, unsigned int j)
Real DLLEXPORT_OST_GEOM SignedAngle(const Vec2 &v1, const Vec2 &v2)
angle beetwen two vectors (honors sign)
Real Length(const Vec2 &v)
returns length of vector
Real Length2(const Vec2 &v)
returns squared length of vector
Vec3List DLLEXPORT_OST_GEOM CalculateUnitCellVectors(const Vec3 &ucell_size, const Vec3 &ucell_angles)
Calculates the Unit Cell Vectors from their sizes and angles (given as Vec3(gamma,...
static const Real EPSILON
bool DLLEXPORT_OST_GEOM Equal(const Line2 &l1, const Line2 &l2, Real ephilon=EPSILON)
Vec2 operator*(const Vec2 &v, const Mat2 &m)
vector matrix multiplication
Mat2 DLLEXPORT_OST_GEOM Transpose(const Mat2 &m)
Transpose.
Real DLLEXPORT_OST_GEOM Comp(const Mat3 &m, unsigned int i, unsigned int j)
Mat3 DLLEXPORT_OST_GEOM AxisRotation(const Vec3 &axis, Real angle)
Mat2 DLLEXPORT_OST_GEOM Invert(const Mat2 &m)
Matrix inversion.
Real DLLEXPORT_OST_GEOM Det(const Mat2 &m)
determinant