Computer-aided simulation of percutaneous needle insertion, as a training tool for junior surgeons, is expected to significantly increase targeting accuracy during minimally invasive operations. This work presents a novel mathematical model, based on the theory of flexible multibody dynamics, that captures the spatial dynamics of needles used for brachytherapy and local anaesthetic transperineal prostate (LATP) biopsy, under a general three-dimensional force field. Due to its accuracy and its computational efficiency, the proposed model is expected to constitute a valuable tool for both real-time visual/haptic simulation and control of percutaneous needle insertion.