00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OBEIGENCONV_H
00021 #define OBEIGENCONV_H
00022
00023 #include <openbabel/math/vector3.h>
00024 #include <openbabel/math/matrix3x3.h>
00025
00026 #include <Eigen/Core>
00027
00028 namespace Avogadro {
00029
00030 inline Eigen::Matrix3d OB2Eigen(const OpenBabel::matrix3x3 &obm)
00031 {
00032 Eigen::Matrix3d mat;
00033 mat(0,0)=obm.Get(0,0);mat(0,1)=obm.Get(0,1);mat(0,2)=obm.Get(0,2);
00034 mat(1,0)=obm.Get(1,0);mat(1,1)=obm.Get(1,1);mat(1,2)=obm.Get(1,2);
00035 mat(2,0)=obm.Get(2,0);mat(2,1)=obm.Get(2,1);mat(2,2)=obm.Get(2,2);
00036 return mat;
00037 }
00038
00039 inline OpenBabel::matrix3x3 Eigen2OB(const Eigen::Matrix3d &mat)
00040 {
00041 OpenBabel::matrix3x3 obm;
00042 obm.Set(0,0,mat(0,0));obm.Set(0,1,mat(0,1));obm.Set(0,2,mat(0,2));
00043 obm.Set(1,0,mat(1,0));obm.Set(1,1,mat(1,1));obm.Set(1,2,mat(1,2));
00044 obm.Set(2,0,mat(2,0));obm.Set(2,1,mat(2,1));obm.Set(2,2,mat(2,2));
00045 return obm;
00046 }
00047
00048 inline Eigen::Vector3d OB2Eigen(const OpenBabel::vector3 &obv)
00049 {
00050 Eigen::Vector3d vec (obv.x(), obv.y(), obv.z());
00051 return vec;
00052 }
00053
00054 inline OpenBabel::vector3 Eigen2OB(const Eigen::Vector3d &vec)
00055 {
00056 OpenBabel::vector3 obv (vec.x(), vec.y(), vec.z());
00057 return obv;
00058 }
00059 }
00060 #endif