Although if you need to do this for many positions, it might be best to get out pen and paper and find the mathematical constraints. You will need to loop this function over every tetrahedron, so if 'many' is really many, this might be impractically slow.
If you edit your question to add some more details about the tetrahedra, we might be able to help you write a much faster function.