MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / dist

Method dist

code/data-structures/kd_tree.cpp:24–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 pt from, to;
23 bb(pt _from, pt _to) : from(_from), to(_to) {}
24 double dist(const pt &p) {
25 double sum = 0.0;
26 rep(i,0,K) {
27 if (p.coord[i] < from.coord[i])
28 sum += pow(from.coord[i] - p.coord[i], 2.0);
29 else if (p.coord[i] > to.coord[i])
30 sum += pow(p.coord[i] - to.coord[i], 2.0);
31 }
32 return sqrt(sum); }
33 bb bound(double l, int c, bool left) {
34 pt nf(from.coord), nt(to.coord);
35 if (left) nt.coord[c] = min(nt.coord[c], l);

Callers

nothing calls this directly

Calls 1

sqrtFunction · 0.85

Tested by

no test coverage detected