double v3mod(V3 v) { double x = 0.0; if (v3GetType(v) == SPHERICAL) { x = fabs(v3GetR(v)); } else { x += v3GetX(v) * v3GetX(v); x += v3GetY(v) * v3GetY(v); x += v3GetZ(v) * v3GetZ(v); x = sqrt(x); } return(x); }
V3 v3diff(V3 v1, V3 v2) { if (v3GetType(v1) == SPHERICAL) { v1 = v3s2c(v1); } if (v3GetType(v2) == SPHERICAL) { v2 = v3s2c(v2); } v3DecX(v1, v3GetX(v2)); v3DecY(v1, v3GetY(v2)); v3DecZ(v1, v3GetZ(v2)); return(v1); }
char * v3fmt(V3 v) { char *p; /* get a buffer */ p = v3buf[nxtv3buf++]; nxtv3buf %= NV3BUF; if (v3GetType(v) == CARTESIAN) { (void)sprintf(p, "%22.15e %22.15e %22.15e", v3GetX(v), v3GetY(v), v3GetZ(v)); } else { (void)sprintf(p, "%22.15e %22.15e %22.15e", v3GetR(v), v3GetAlpha(v), v3GetDelta(v)); } return(p); }