Cylinders and Quadric Surfaces
Planes are the graphs of first-degree equations in , and . Second-degree equations give the quadric surfaces: ellipsoids, paraboloids, cones and hyperboloids. This lesson shows how to identify them by their traces, classifies the six standard types, and ends with the ray–sphere test and the quadric shapes used for collision in games.
For a gentler first look, see Surfaces. The 2D cross-sections are the conics from Conic Sections.
Cylinders
A cylinder is the surface made of all lines (called rulings) parallel to a given line and passing through a given plane curve. In practice: if one variable is missing from the equation, the surface is a cylinder parallel to that variable's axis.
| Equation | Surface |
|---|---|
| circular cylinder of radius 2 around the -axis | |
| parabolic cylinder: the parabola slid along the -axis | |
| elliptic cylinder around the -axis |
Traces
The trace of a surface in a plane is the curve where they intersect. To recognise a surface, set , and in turn and identify the resulting conics. Traces are also exactly the contour lines you meet in the next chapter (Functions of Several Variables).
Example: . In the trace is the ellipse , which grows as grows. In the trace is the parabola , and in the parabola . The surface is an elliptic paraboloid, a bowl opening upward.
The quadric surfaces
The general second-degree equation can be reduced by a rotation and a translation to one of two standard forms: or . The nondegenerate cases are:
| Surface | Standard equation | Traces | Shape |
|---|---|---|---|
| Ellipsoid | all ellipses | closed egg; a sphere if | |
| Elliptic paraboloid | horizontal: ellipses; vertical: parabolas | bowl | |
| Hyperbolic paraboloid | horizontal: hyperbolas; vertical: parabolas | saddle | |
| Cone | horizontal: ellipses; vertical: hyperbolas or line pairs | double cone | |
| Hyperboloid of one sheet | horizontal: ellipses; vertical: hyperbolas | cooling tower, connected | |
| Hyperboloid of two sheets | horizontal: ellipses (); vertical: hyperbolas | two bowls, a gap between |
Reading the signs: with all three squares positive and , you have an ellipsoid; one minus sign gives one sheet; two minus signs give two sheets. A linear term in place of a square gives a paraboloid. The variable whose sign differs (or that appears linearly) names the axis.
Note: The saddle reappears in Maximum and Minimum Values as the standard picture of a saddle point: a critical point that is neither a maximum nor a minimum, common in the loss landscapes of deep networks.
Both the hyperboloid of one sheet and the hyperbolic paraboloid are doubly ruled: through every point pass two straight lines lying entirely in the surface. That is why cooling towers and some roofs can be built from straight beams.
import numpy as np
# show that the line (1, 0, 0) + t(0, 1, 1) lies on x² + y² − z² = 1
t = np.linspace(-5, 5, 11)
x, y, z = 1 + 0 * t, t, t
print("x²+y²−z² along the line:", np.unique(x**2 + y**2 - z**2))
# and that z = x² − y² contains the line (t, t, 0) and (t, −t, 0)
print("saddle on (t, t, 0):", np.unique(t**2 - t**2 - 0))x²+y²−z² along the line: [1.]
saddle on (t, t, 0): [0.]
Identifying by completing the square
Classify :
import sympy as sp
x, y, z = sp.symbols("x y z")
expr = 4*x**2 + y**2 - 4*z**2 - 8*x + 2*y + 1
standard = 4*(x - 1)**2 + (y + 1)**2 - 4*z**2 - 4 # completed squares
print("difference:", sp.expand(standard - expr))
print("so (x−1)² + (y+1)²/4 − z² = 1 → hyperboloid of one sheet, axis parallel to z, centre (1, −1, 0)")difference: 0
so (x−1)² + (y+1)²/4 − z² = 1 → hyperboloid of one sheet, axis parallel to z, centre (1, −1, 0)
Ray–sphere intersection
A sphere and a ray (unit ) meet where
The discriminant decides: negative means a miss, zero a tangent graze, positive two hits (entry and exit). The nearest hit with is the one you see. Every quadric gives a quadratic in in the same way, which is why quadrics are the cheapest curved primitives in a ray tracer.
import numpy as np
def ray_sphere(o, d, c, r):
m = o - c
b, cc = d @ m, m @ m - r * r
disc = b * b - cc
if disc < 0:
return None
s = np.sqrt(disc)
for t in (-b - s, -b + s): # nearest first
if t >= 0:
return float(t)
return None # sphere behind the ray
c, r = np.array([0.0, 0.0, 5.0]), 1.0
o = np.zeros(3)
for d in [(0, 0, 1), (0.1, 0, 1), (0.2, 0, 1), (0, 0, -1)]:
d = np.array(d, float) / np.linalg.norm(d)
t = ray_sphere(o, d, c, r)
print(np.round(d, 3), "->", "miss" if t is None else f"t = {t:.4f}, hit {np.round(o + t * d, 3)}")[0. 0. 1.] -> t = 4.0000, hit [0. 0. 4.]
[0.1 0. 0.995] -> t = 4.1077, hit [0.409 0. 4.087]
[0.196 0. 0.981] -> t = 4.7068, hit [0.923 0. 4.615]
[ 0. 0. -1.] -> miss
At the hit point, the outward normal is . For a general quadric , the normal is the gradient , as you will see in Directional Derivatives and the Gradient Vector.
In software
- Collision shapes. Physics engines love quadrics because their tests are closed-form: spheres (distance to centre ), capsules (a segment plus a radius: the set of points within of a segment), cylinders, and ellipsoids. An ellipsoid is a sphere under a non-uniform scale, so engines transform the ray or the other shape by the inverse scale and run the sphere test. Character controllers are usually capsules (Circles and Spheres, Ray–Sphere, Collision Pipeline).
- Bounding volumes. Bounding spheres and boxes (AABB) wrap complex meshes so that most collision pairs are rejected cheaply.
- Optics and antennas. Paraboloids focus parallel rays to a point, which is why satellite dishes, headlights and telescope mirrors use them.
- Optimisation. Near a minimum, a smooth loss looks like an elliptic paraboloid. Near a saddle, it looks like the hyperbolic paraboloid. That picture drives the second-derivative test and the analysis of gradient descent.
Exercises
Exercise 1: Name the surface
Identify (a) , (b) , (c) , (d) .
Answer
(a) Sphere of radius 3 centred at the origin. (b) Elliptic (here circular) paraboloid around the -axis. (c) Hyperboloid of two sheets with axis the -axis. (d) Hyperbolic paraboloid (saddle).
Solution
(a) . (b) is linear and the squares have the same sign, so it is a paraboloid opening toward . (c) Multiply by : . Two minus signs give two sheets, and the positive variable is the axis. (d) The squares have opposite signs and is linear, so it is a saddle.
Exercise 2: Traces
Describe the traces of in the planes , and .
Answer
: the ellipse . : the larger ellipse . : the hyperbola .
Solution
At : . Divide by 5: . At : , a hyperbola opening along .
Exercise 3: Where does the ray hit? (pencil, then code)
A ray starts at with direction . Find the first at which it hits the sphere centred at with radius 3, and the hit point.
Answer
, hit point .
Solution
The ray goes straight through the centre, so the exit is at .
import numpy as np
o, d, c, r = np.zeros(3), np.array([2.0, 1.0, 2.0]) / 3, np.array([4.0, 2.0, 4.0]), 3.0
m = o - c
b, cc = d @ m, m @ m - r * r
ts = [float(-b - np.sqrt(b * b - cc)), float(-b + np.sqrt(b * b - cc))]
print("t values:", [round(t, 6) for t in ts], " first hit:", np.round(o + ts[0] * d, 6))t values: [3.0, 9.0] first hit: [2. 1. 2.]
Exercise 4: Ellipsoid via scaling
Explain how to intersect a ray with the ellipsoid using only a unit-sphere routine.
Answer
Scale space by . The ellipsoid becomes the unit sphere, and the ray becomes , . Solve for with the sphere test, keeping unnormalised (or rescaling ), and map the hit back with .
Solution
The map sends the ellipsoid onto , and it is linear, so it sends the line to with the same parameter . Solve , which is a quadratic in (keep the coefficient, since is not a unit vector). The same plugged into gives the hit on the original ellipsoid. Normals do not transform the same way: they need the inverse-transpose scale.
Test yourself
What surface is in ?
- A circle
- A sphere
- A circular cylinder around the -axis
- A cone
is a…
- hyperboloid of one sheet
- cone
- hyperboloid of two sheets
- ellipsoid
In a ray–sphere test, what does a negative discriminant mean?
- The ray grazes the sphere
- The ray starts inside the sphere
- The ray misses the sphere
- The hit is behind the ray