How to mathematically define a torus in a volume
This can be achieved by using the following node setup:



The formula which I implemented in order to achieve this can be found in the Wikipedia article for Torus. Note that this only works for tori whose big radius is greater than or equal to it's small radius.