#include "Torsion_energy_HC_CT_CT_HC_amber.h"

#include "Atom.h"
#include "Geometry.h"

namespace MM
{

double Torsion_energy_HC_CT_CT_HC_amber::
handle_value() const
{
    //T1    T2	T3	T4	MULT	HALF_VN	GAMMA	N	REFERENCE
    //**    CT  CT  **   9      1.40    0.0     3   JCC,7,(1986),230
    /*double p1[3],p2[3],p3[3],p4[3];
	p1[0] = atom1_.x();
	p1[1] = atom1_.y();
	p1[2] = atom1_.z();

   	p2[0] = atom2_.x();
	p2[1] = atom2_.y();
	p2[2] = atom2_.z();

	p3[0] = atom3_.x();
	p3[1] = atom3_.y();
	p3[2] = atom3_.z();

	p4[0] = atom4_.x();
	p4[1] = atom4_.y();
	p4[2] = atom4_.z();
	
	double angle = Geometry_util::diheral_by_four_poins (p1,p2,p3,p4);//*/
	double angle = torsion (atom1_, atom2_, atom3_, atom4_);
//    double angle	 = acos(cos_angle);

    //double angle_0	 = (109.50 / 180) * 3.14159265358979323846;
	double result	 = 1.40 * (1 + cos (3*angle - 0.)) / 9 ;
    return result;
}

Torsion_energy_HC_CT_CT_HC_amber::
Torsion_energy_HC_CT_CT_HC_amber
    (const Atom & atom1, const Atom & atom2, 
     const Atom & atom3, const Atom & atom4)
:
    atom1_(atom1), atom2_(atom2), atom3_(atom3), atom4_(atom4)
{
}

}//MM
