# Intersection between a horizontal plane and a torus. Problem with complex values

[EDIT: I have replaced $$a$$ by $$R_1$$ in my previous post to make your reading and understanding easier, as this is a more general expression.]

I think I have a basic question but I cannot figure out an easy solution. I am intersecting a torus with an horizontal plane, which I will move from the upper part to the bottom to calculate the area the intersections at different heights. Thus, I need to obtain the parametric curve equation of each intersection to compute the area as: $$A=\int{y(v) x'(v) dv}$$.

My problem is that I am unable to obtain a "closed" parametric curve, since there are certain complex values in the calculation that I cannot avoid. I obtain something like this when I cut the torus in the region between the inner and outter diameters:

intersection between plane and torus (parametric curve as black line)

Parametric intersection curve

Parametric intersection curve plus its negative counterpart

As can be seen, even trying to replicate the full geometry by the addition of the negative values parametric curve (just in case this solves something...), there is a small region that does not allow any connection to create a full closed curve to be integrated to obtain the enclosed area.

Does anyone know what am I doing wrong? I would appreciate any help a lot.

Details of my procedure:

Parametric equations of the torus: $$x(u,v) = R_2*\sin(v),$$ $$y(u,v) = (R_1+R_2\cos(v))\cos(u),$$ $$z(u,v) = (R_1+R_2\cos(v))\sin(u),$$ with $$v \in [0, 2\pi]$$, $$u \in [0, 2\pi]$$, $$R_1$$ the radial position of the center of the revolutioned circunference, and $$R_2$$ the radius of the said circunference in revolution.

Parametric equations of the plane: $$z(x,y)=h,$$ with $$h$$ an specific height which will be varied. It is just a horizontal plane.

To obtain the parametric curves, I have to make equal both $$z$$ values: $$(R_1+R_2\cos(v))\sin(u) = h,$$ Thus: $$\sin(u) = \frac{h}{R_1+R_2\cos(v)}$$. I can substitute this value in y(u,v) to obtain y(v) by either using $$u=\arcsin(\frac{h}{R_1+R_2\cos(v)})$$ or $$\cos(u)=\sqrt{1-\sin(u)^2}$$. By using the latter one, we can get the following parametric curve for the intersection:

$$x(v) = R_2*\sin(v),$$ $$y(v) = (R_1+R_2\cos(v))\sqrt{1-\left(\frac{h}{R_1+R_2\cos(v)}\right)^2},$$ with $$v \in [0, 2\pi]$$.

When $$\left(\frac{h}{R_1+R_2\cos(v)}\right)^2$$ > 1, the square root yields the said problematic complex values.

Best regards.

[EDIT: An easy working Matlab script to visualize this situation:]

close all;
R1=3; R2=1;
h=3.7; %Example of height
L1=4; L2=4; %some limits for the plane

%Plane equation
syms u v
yp=v;
zp = h;
xp = u;
fsurf(xp, yp, zp, [-(L1 + 2*R1)/2, (L1 + 2*R1)/2 , -(L2 + 2*R2)/2, (L2 + 2*R2)/2], 'LineStyle', ls, 'FaceColor', 'm'); hold on;

%Torus equation
syms u v
%a=R1+R2;
x_t = R2*sin(v);
y_t = (R1+R2*cos(v))*cos(u);
z_t = (R1+R2*cos(v))*sin(u);
fsurf(x_t, y_t, z_t, [0, 2*pi, 0, 2*pi], 'LineStyle', ls, 'FaceColor', 'g');

%Intersection
syms v
x_i = R2*sin(v);
y_i = (R1+R2*cos(v)).*(sqrt(1-(h/(R1+R2*cos(v)))^2) ) ;
z_i=h+v-v; %tricky to plot a 2D plot in a 3D figure
fplot3(x_i,y_i,z_i, [0, 2*pi], 'k-', 'LineWidth', 4); xlabel('x')
hold on

syms v
x_i = R2*sin(v);
y_i = -(R1+R2*cos(v))*(sqrt(1-(h/(R1+R2*cos(v)))^2) ) ;
z_i=h+v-v; %tricky to plot a 2D plot in a 3D figure
fplot3(x_i,y_i,z_i, [0, 2*pi], 'k-', 'LineWidth', 4); xlabel('x')
hold on


• Is it possible that those values of $h$ correspond to non-intersections? Nov 15, 2021 at 11:37
• @preferred_anon Thanks for your reply. No, I am pretty sure there is intersection, as shown in the figures Nov 15, 2021 at 11:50
• Your problem seems to go away in geogebra. Nov 16, 2021 at 12:30
• @Jan-MagnusØkland Thank you so much for your valuable response!!! I wonder whether this is a consequence of MATLAB precision (e.g. sqrt(1-1.000001) yields a complex number rather than 0). How is v varied in your Geogebra computation? Between 0 and 2pi too? Best regards Nov 16, 2021 at 13:24
• That's right. The commands used are Curve and Surface. Nov 16, 2021 at 13:28

Hint:

Using the cartesian equation of the torus $$\left(R_2-\sqrt{x^2+y^2}\right)^2+z^2=R_1^2$$

you can arrive at an equation of the form $$y=f(x,z)$$

• I would need in principle the parametric equations, since my problem is more complicated (I create pieces of torus joined to other volumes, controled by the angles v and u in the equations above). However, your suggestion may be interesting in case I am desperated not being able to solve this! Nov 15, 2021 at 11:58

After creating a Geogebra simulation and trying other ways in MATLAB to plot this (simply to use the standard plot() command), I can confirm that my problem was only related to visualisation in MATLAB when using fplot()/fplot3() for parametric plotting. My "issue" with complex numbers simply had nothing to do with this. These numbers do not contribute to the plot. I hope this helps anyone else.