(TYPE_1)get_x()
...
switch (typeid(T))
a = vx*vx+vy*vy+vz*vz
b = 2*(vx*(x0-xs)+vy*(y0-ys)+vz*(z0-zs))
c = (x0-xs)*(x0-xs)+(y0-ys)*(y0-ys)+(z0-zs)*(z0-zs) - r*r
d = b*b-4*a*c.
if (t1 > 0) t = t1;
else t = t2;
if (t <= 0) решения_нет;
x = x0+t*vx
y = y0+t*vy
z = z0+t*vz
(dx), (dy = ...), ...
.