#ifndef _POINT_HPP_ #define _POINT_HPP_ #include #include struct point { point(); point(double x_,double y_,double z_=0) :x(x_) ,y(y_) ,z(z_) { d1 = 0.0; d2 = 0.0; d3 = 0.0; site1 = 0; site2 = 0; site3 = 0; } point(const point&pt) :x(pt.x) ,y(pt.y) ,z(pt.z) ,d1(pt.d1) ,d2(pt.d2) ,d3(pt.d3) , site1(pt.site1) , site2(pt.site2) , site3(pt.site3) { } static point min(const point&a,const point&b) { return bx-x; double dy=this->y-y; return sqrt(dx*dx+dy*dy); } double cos_k(const point&o)const { double dx=o.x-x; double dy=o.y-y; return dx/sqrt(dx*dx+dy*dy); } double sin_k(const point&o)const { double dx=o.x-x; double dy=o.y-y; return dy/sqrt(dx*dx+dy*dy); } point middle(const point&o)const { return point((x+o.x)/2,(y+o.y)/2); } std::tuple get_abc(const point&o)const { double cos=fabs(cos_k(o)); if(cos==0) return std::make_tuple(1,0,-x); if(cos==1) return std::make_tuple(0,1,-y); double dx=o.x-x; double dy=o.y-y; double k=dy/dx; double deno=sqrt(k*k+1); return std::make_tuple(k/deno,-1/deno,(y-k*x)/deno); //return std::make_tuple(k,-1,y-k*x); } double value() { return (x*x + y*y + z*z); } public: double x,y,z; double d1, d2, d3; int site1; int site2; int site3; }; #endif