# Visualizing Viviani's curve

Viviani's curve is the line of intersection between a sphere of radius $2a$ and a cylinder of radius $a$ which is tangent to the sphere and also passes through its centre.

The shape has the following parametric equation:

$$f(t) = \left( a(1+\cos t), a \sin t, 2a\sin \textstyle \frac{t}{2} \right), \quad 0 \le t \le 4\pi.$$

It is calculated and plotted using Matplotlib in the following code.

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

a = 1

# Number of points of the parametric function to calculate.
n = 100
t = np.linspace(0, 4*np.pi, n)
# Cartesian coordinates of the Viviani curve.
x = a * (1 + np.cos(t))
y = a * np.sin(t)
z = 2 * a * np.sin(t/2)

fig = plt.figure(figsize=plt.figaspect(1.))

# Outline the intersecting sphere and cylinder in light grey circles.
ng = n//2 + 1
# We only need to go from 0 to 2π for circles!
theta = t[:ng]
for phi in np.linspace(-np.pi,np.pi,32):
# Circles on the sphere in two perpendicular planes.
ax.plot(2*a*np.sin(theta)*np.cos(phi), 2*a*np.cos(theta)*np.cos(phi),
2*a*np.sin(phi), 'gray', alpha=0.2, lw=1)
ax.plot(2*a*np.cos(theta)*np.cos(phi), [2*a*np.sin(phi)]*ng,
2*a*np.sin(theta)*np.cos(phi), 'gray', alpha=0.2,lw=1)
# The circles of the cylinder.
ax.plot(a*np.sin(theta)+a, a*np.cos(theta), 2*a*phi/np.pi,
'm', alpha=0.2, lw=1)

ax.plot(x, y, z, 'r', lw=4)

# Tidy up by switching off the axes and setting the view orientation.
ax.set_axis_off()
ax.view_init(0, 50)
plt.savefig('viviani.png')
plt.show()

Current rating: 3.7

#### Bodale Laurentiu-Marius 8 months, 2 weeks ago

If I remember well the Viviani's curve is related whit a problem at the begining of calculus:The Geometry have Temple whit a hemisphere at the top(which stay on seven pillars),in which are practiced four holes in such a way that surface left is perfectly quadratic?.Well,I'm not a matematician,exactly,how much is the surface left?Maybe a demonstration?