Matrix4Symmetry.C

Go to the documentation of this file.
00001 #include "Matrix4Symmetry.h"
00002 
00003 Matrix4Symmetry::Matrix4Symmetry() { identity(); }
00004 Matrix4Symmetry::Matrix4Symmetry(const BigReal *m)  { memcpy(mat, m, 16*sizeof(BigReal)); }
00005 Matrix4Symmetry::Matrix4Symmetry(BigReal arr []){
00006     for(int i = 0; i < 16; i++){mat[i] = arr[i];}
00007   }
00008 void Matrix4Symmetry::multpoint(BigReal point[3]) const {
00009     BigReal tmp[3];
00010     BigReal itmp3 = 1.0f / (point[0]*mat[3] + point[1]*mat[7] +
00011                             point[2]*mat[11] + mat[15]);
00012     tmp[0] = itmp3*point[0];
00013     tmp[1] = itmp3*point[1];
00014     tmp[2] = itmp3*point[2];
00015     point[0]=tmp[0]*mat[0] + tmp[1]*mat[4] + tmp[2]*mat[ 8] + itmp3*mat[12];
00016     point[1]=tmp[0]*mat[1] + tmp[1]*mat[5] + tmp[2]*mat[ 9] + itmp3*mat[13];
00017     point[2]=tmp[0]*mat[2] + tmp[1]*mat[6] + tmp[2]*mat[10] + itmp3*mat[14];
00018   }
00019 
00020 void Matrix4Symmetry::identity() {
00021     memset(mat, 0, 16*sizeof(BigReal));
00022     mat[0]=1.0f;
00023     mat[5]=1.0f;
00024     mat[10]=1.0f;
00025     mat[15]=1.0f;
00026   }
00027 void Matrix4Symmetry::transpose() {
00028     BigReal tmp[16];
00029     int i,j;
00030     for(i=0;i<4;i++) {
00031       for(j=0;j<4;j++) {
00032         tmp[4*i+j] = mat[i+4*j];
00033       }
00034     }
00035     for(i=0;i<16;i++) mat[i] = tmp[i];
00036   }
00038 void Matrix4Symmetry::multmatrix(const Matrix4Symmetry &m) {
00039     BigReal tmp[4];
00040     for (int j=0; j<4; j++) {
00041       tmp[0] = mat[j];
00042       tmp[1] = mat[4+j];
00043       tmp[2] = mat[8+j]; 
00044       tmp[3] = mat[12+j];
00045       for (int i=0; i<4; i++) {
00046         mat[4*i+j] = m.mat[4*i]*tmp[0] + m.mat[4*i+1]*tmp[1] +
00047           m.mat[4*i+2]*tmp[2] + m.mat[4*i+3]*tmp[3]; 
00048       }
00049     } 
00050   }
00051 void Matrix4Symmetry::translate(BigReal x, BigReal y, BigReal z) {
00052     Matrix4Symmetry m;          
00053     m.mat[12] = x;
00054     m.mat[13] = y;
00055     m.mat[14] = z;
00056     multmatrix(m);
00057   }
00058 void Matrix4Symmetry::translate(BigReal d[3]) { translate(d[0], d[1], d[2]); }

Generated on Mon Nov 20 01:17:13 2017 for NAMD by  doxygen 1.4.7