#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_) { } point(const point&pt) :x(pt.x) ,y(pt.y) ,z(pt.z) { } 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); } public: double x,y,z; }; #endif