Here is problem. I have one torus defined in space by coordinates $(x, y, z)$ and it can be rotated in any direction. You can imagine it as torus total free in space. Torus is defined by two radius $(R, r)$ as well. This torus is ring torus. For example: location $(10, 10, 10)$ rotation $(20^\circ, 20^\circ, 20^\circ)$ $R=50$, $r=1$
1) How to test is given point $M(x, y)$ is inside that torus?
2) If I have another torus with same $(R, r)$ and it has two points that belong to both torus how I can calculate $x$, $y$, $z$ and rotation in space for the second torus? (I have all information for first torus and coordinates for two points)
3) This is a variation of the second question. If I have two tori with same $(R, r)$ and $x$, $y$, $z$ and rotations in space, how do I calculate intersection points (one or two points that is located on surface and belong to both torus - like on image). Of course if those points exist for given conditions.
The simplest answer is better. I need it for software.
Thanks!