Vector_norm(Vector_minus(pos, this.center)); } function Vector_minus(v1: Vector, v2: Vector): Vector { return new Vector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); } function Vector_norm(v: Vector): Vector { var mag = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); var div = mag === 0 ? Infinity : 1.0 / mag; return new Vector(div * v.x, div * v.y, div * v.z); }