The formula is pretty much the same. but because of the new z-axis in 3D, we have to add the z-coordinates into the formula.