Distance formula wrong?

everyone knows the distance formula in 3 dimensional
d = sqrt[(x1-x2)2 + (y1-y2)2 + (z1-z2)2]

but when i apply to flash

rd = m.sqrt(m.pow((a.x-_root.o.x), 2)+m.pow((a.y-_root.o.y), 2)+m.pow((a.z-_root.o.z), 2))

and i make some changes

c = point1
o = origin point
rx / ry = how much value to add
//x rotation
//new x angle
var ax2 = (m.atan2((c.z-o.z), (c.x-o.x)))+rx;
c.x = o.x+(m.sin(ax2)*rd);
c.z = o.z+(m.cos(ax2)*rd);
//y rotation
//new y angle
var ay2 = (m.atan2((c.y-o.y), (c.z-o.z)))+ry;
c.z = o.z+(m.sin(ay2)*rd);
c.y = o.y+(m.cos(ay2)*rd);

somehow the distance keeps increasing. even though i removed the rx and ry
is my distance formula wrong or is it my rotation wrong?
please reply asap. :ne: