Skip to content

Commit

Permalink
more robust periodic boundary checks using atan2
Browse files Browse the repository at this point in the history
  • Loading branch information
lettis committed Dec 9, 2015
1 parent 9ecae71 commit 5ecbdad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/file_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdlib>
#include <set>

//TODO remove, use system implementation
//#define PI (3.14159265358979323846264338327950288)

#include "file_io.hpp"
#include "covariance.hpp"

Expand Down Expand Up @@ -127,7 +124,7 @@ namespace FastPCA {
DataFileReader<double> fh_file_in(file_in, mem_buf_size);
DataFileWriter<double> fh_file_out(file_out);
//TODO debug
DataFileWriter<double> fh_dih_shift_out("zzz_dih_shifted.dat");
//DataFileWriter<double> fh_dih_shift_out("zzz_dih_shifted.dat");
bool append_to_file = false;
while ( ! fh_file_in.eof()) {
Matrix<double> m = fh_file_in.next_block();
Expand All @@ -137,7 +134,7 @@ namespace FastPCA {
FastPCA::deg2rad_inplace(m);
FastPCA::Periodic::shift_matrix_columns_inplace(m, dih_shifts);
//TODO debug
fh_dih_shift_out.write(m, append_to_file);
//fh_dih_shift_out.write(m, append_to_file);
} else {
// default behaviour: shift by periodic means
FastPCA::deg2rad_inplace(m);
Expand Down
6 changes: 1 addition & 5 deletions src/util.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,7 @@ namespace FastPCA {
for (i=0; i < n_rows; ++i) {
m(i,j) = m(i,j) - shifts[j];
// periodic boundary checks
if (m(i,j) < -M_PI) {
m(i,j) = m(i,j) + 2*M_PI;
} else if (m(i,j) > M_PI) {
m(i,j) = m(i,j) - 2*M_PI;
}
m(i,j) = atan2(sin(m(i,j)), cos(m(i,j)));
}
}
}
Expand Down

0 comments on commit 5ecbdad

Please sign in to comment.