double dist(Pt p) const { if (between(s, e, p)) { // printf("%lf %lf\n", cross(s, e, p), s.dist(e)); return fabs(cross(s, e, p))/s.dist(e); } return min(s.dist(p), e.dist(p)); }
double computeDistances (const Pt& cg, const Pt& p1, const Pt& p2, const Pt& p3, double w1, double w2, double w3) { double dist1 = p1.dist(cg); double dist2 = p2.dist(cg); double dist3 = p3.dist(cg); dist1 *= w1; dist2 *= w2; dist3 *= w3; double result = dist1 + dist2 + dist3; return result; }