<commit_before>#include <iostream>
#include <cmath>
#include <fstream>

using namespace std;

/**calculates dihedral angle between planes i-j-k and j-k-l*/
double Dihedral_Angle() {
    
    double ex_ijk = ((ey_ji*ez_jk)-(ez_ji*ey_jk));
    
    double ey_ijk = ((ez_ji*ex_jk)-(ex_ji*ez_jk));
    
    double ez_ijk = ((ex_ji*ey_jk)-(ey_ji*ex_jk));
    
    double ex_jkl = 
    
    double e_ji(double ex_ji, double ey_ji, double ez_ji); 

    double e_jk(double ex_jk, double ey_jk, double ez_jk);   

    double e_kl(double ex_kl, double ey_kl, double ez_kl); 

    double tau_ijkl(double ex_ji, double ey_ji, double ez_ji, double ex_jk, double ey_jk, double ez_jk, double ex_kl, double ey_kl, double ez_kl, double phi_ijk, double phi_jkl) {
    
    double e_ji[3] = {ex_ji, ey_ji, ez_ji};<commit_msg>version with comments and fixes<commit_after>#include <iostream>
#include <cmath>
#include <fstream>
#include "dihedral_angle.h"

using namespace std;

//calculates dihedral angle between planes i-j-k and j-k-l
double dihedral_angle() {
    
    //cross product of unit vectors
    double ex_ijk = ((ey_ji * ez_jk) - (ez_ji * ey_jk));
    
    double ey_ijk = ((ez_ji * ex_jk) - (ex_ji * ez_jk));
    
    double ez_ijk = ((ex_ji * ey_jk) - (ey_ji * ex_jk));
    
    double ex_jkl = ((ey_kl * ez_kl) - (ez_kj * ey_kl));
    
    double ey_jkl = ((ez_kj * ex_kl) - (ex_kj * ez_kl));
    
    double ez_jkl = ((ex_kj * ey_kl) - (ey_kj * ex_kl));
    
    //dot product and calculation of dihedral angle (tau)
    double exx = (ex_ijk * ex_jkl);
    
    double eyy = (ey_ijk * ey_jkl);
    
    double ezz = (ez_ijk * ez_jkl);
    
    double tau_ijkl = (exx + eyy + ezz) / (sin(phi_ijk)*sin(phi_jkl));
    
    //ensure dihedral angle is not negative before addition of sign
    if(tau_ijkl < -1.0) tau_ijkl = acos(-1.0);
    else if(tau_ijkl > 1.0) tau_ijkl = acos(1.0);
    else tau_ijkl = acos(tau);
    
    return tau_ijkl;
    
}

//determines sign of dihedral angle
double sign_tau() {
    
    double cross_yz = (ey_ijk * ez_jkl) - (ez_ijk * ey_jkl);
    
    double cross_xz = (ez_ijk * ex_jkl) - (ex_ijk * ez_jkl);
    
    double cross_xy = (ex_ijk * ey_jkl) - (ey_ijk * ex_jkl);
    
    double normal = cross_yz * cross_yz + cross_xz * cross_xz + cross_xy * cross_xy;
    
    cross_yz /= normal;
    
    cross_xz /= normal;
    
    cross_xy /= normal;
    
    double sign = 1.0;
    
    double dot = (cross_yz * ex_jk) + (cross_xz * ey_jk) + (cross_xy * ez_jk);
    
    if(dot < 0.0) sign = -1.0;
    
    return tau_ijkl * sign;
    
}
{'fraction_non_alphanumeric': 0.12690355329949238, 'fraction_numerical': 0.005857087075361187, 'mean_word_length': 2.6810344827586206, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2311866', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1041, 'n_words': 251}