Electrostatic forces between sharp tips and metallic and dielectric samples