Analytical derivation of the geometric factor of a particle detector having circular or rectangular geometry