Hi Everyone,
Here’s a little project that might be worth sharing. My project has two goals:
(1) To teach myself about NURBS, I wanted to do a little exercise in representing conic curves (circles, ellipses, parabolas, hyperbolas) as NURBS curves “exactly.”
(2) We know if you slice a cone with a plane that you get a conic section (curve). But what if you start with a conic curve, and then you ask what cone(s) are possible?
For example, you might slice a cone to get a hyperbola. But if I give you a specific hyperbola, then what are all possible cones that could’ve been sliced to make that hyperbola?
Below I briefly sketch out some results for (1) and (2). But, appologies in advance, as I haven’t the time (or interest) to fully explain everything. None of the math is new, so I will ditch the effort of making a decent presentation, and instead I’ll just point to some books.
If you don’t know about “homogeneous coordinates” (also called “projective coordinates”), then you won’t understand (1), which is about the “rational” part of Non-Uniform-Rational-B-Splines (NURBS). I think it’s fine to read about what I did, and look at the pictures, even if you don’t understand; at least you’ll get a vague flavor of how NURBS use weighted vertices.
I’ll also give the results for (2), but without deriving the math. Technically, it’s solid-geometry from high-school. If you’re interested in such questions (given a conic curve, how do you find it’s cones?), then I can recommend the classic book (with wonderful diagrams):
Geometry and the Imagination by David Hilbert and Cohn-Vossen
If you can, buy or borrow the printed version, because the electronic version has low-resolution scans of the diagrams.
For NURBS curves and surfaces, there are zillions of textbooks about it, but I am personally working through Farin’s book. He goes through the history of splines, homogeneous coordinates, to NURBS curves and surfaces and their curvature.
Curves and Surfaces for CAGD: A Practical Guide by Gerald Farin
Feel free to skip any section below, or just hop through the pictures.
Part (1) “Exact” Representations of Conic Curves by using NURBS.
In rational B-splines we attach a “weight” w to each control point of the spline. The larger the weight, the closer the spline approaches the control point. Without going into the technical details: we’ll use an extra dimension to represent the weight. So for a NURBS curve in 3d, we’ll work in a 4d space. We’ll use a non-rational B-spline in 4d space, and then “project down” to 3d space.
All that is abstract and confusing, so to make it easier, let’s work with NURBS curves in 2d (ie: curves in the xy-plane). Then we’ll use the z-axis to represent our extra dimension.
Here is a contrived example. In cyan, we have a uniform-B-spline in 3d. We’ll project it down to a 2d curve by a perspective transform. In this case,we see that if our original curve (cyan) is on a cone, then it is possible to exactly represent a circle (yellow circle) after our perspective transform.
The cyan curve is a non-rational B-spline, but after the perspective transform, we get a rational-B-spline (yellow circle). This is the “rational” part of NURBS (non-uniform-rational-B-spline). For details on how all that works and the math, see Farin’s book.
Non-rational B-splines are just simple polynomials, so it is natural for them to represent things like parabolas. Parabolas are conic-sections, so, obviously, they lie on cones. This is the basis for how NURBS are used to represent circles exactly.
Here’s a circle in the XY-plane. We’ll use the Z-axis to represent our “extra” dimension that encodes weights of control points.
Next, we introduce our “extra” dimension. We’ll place our “eye” at (0,0,0) and put our “canvas” at Z=1.
Our circle will be represented by four parabolic segments (red) in 3d space. Although these are four separate curves, with corners, when we place our eye at the origin, we will see a circle. We can imagine drawing on a canvas (or glass window) at Z=1. This is how most CAD programs use NURBS to represent a circle. However, this representation is not unique; for example, our cyan curve above also represents a circle exactly.
From here we see that if we were to tilt the cone, the perspective transform can give us other conic curves. For example, the perspective transform of a circle can get us ellipses.
As a teaching exercise, for myself, I decided to implement this in Grasshopper. I can ask Rhino for a circle, and then get the control-points and their weights. From there, I have an “implicit cone” which I can tilt. I do this by taking the control points (x,y,z,w) and converting it to (x,y,w) which is “3d” and z=0 is just dropped. Then I do a 3d rotation on (x,y,w), and then jump back up to (x,y,z,w) with z=0 (because I’m only working in the xy-plane). Then using (x,y,z,w), I construct a NURBS curve.
(Technical note (feel free to ignore): This is conceptually correct, although mathematically over-simplified because I haven’t put in the perspective transforms. So actually we have (x,y,z,w)–>(wx,wy,w) and (x,y,w)–>(x/w,y/w,z=0,w) where the extra division and multiplications represent perspective transforms. For the math details, I’ll point to Farin’s book.)
Doing all that, gives me a perspective transform on a circle. As you might guess, the control polygon becomes a trapazoid (in general, a quadralateral, which is a perspective transform of a square). We have an exact ellipse using NURBS.
Depending on how much you tilt the “cone” you can also get other conics, like parabolas and hyperbolas.
On the other hand, if I just tell Rhino to slice the cone, it will use uniform-non-rational-b-splines to approximate the ellipse. This leads to lots of extra control points. Here we have a non-exact ellipse using uniform-non-rational-B-splines.
Okay, here’s a code snippet I used to create the two pictures above (in case you want to play around). They’re included in the .zip file at the end. See Farin for details on the math.
Part (2) Fun with Conics
From Part (1), I have a way of generating “exact” conic curves using Grasshopper. The above IS NOT the best way to make conics using NURBS. For an ellipse, a rectangle is much more intuitive and usable as a control polygon than a trapazoid or other quadrilateral. But hey, this is “my” way of playing around to learn about NURBS.
So let’s look at conic curves. Here’s a classic diagram you might see in any high-school geometry book.
As you probably know, the green curves (edges) represent circles, ellipses, parabolas, and hyperbolas.
With my playing around, I can represent them exactly using NURBS, or I can approximate them by “cutting” solid geometry in Rhino.
There’s a beautiful theorem for locating the focii of these conic curves using spheres. Roughly speaking, you try to find the largest sphere(s) that can be tangent to the plane of the conic, while also having a circle-of-tangency with the cone. See Hilbert and Cohn-Vossen for how/why this works. Here are some examples.
Circle
Ellipse
Parabola
If you try to insert a sphere below the parabola’s plane, you will find you can’t do it: you can’t make such a sphere tangent to the plane while also having a circle-of-tangency with the cone. So there is only one focus.
Hyperbola
Without explaining why, for the hyperbola case, we think of the cone as a “double cone” where our cutting plane slices both cones. See Hilbert’s book for details.
Okay, that was fun for me. But usually we think of this as starting out with some cone, and then slicing it with some plane to get a conic section.
But what about the reverse process? Suppose I gave you a conic section. Could you tell me what cone(s) it came from? I call this problem “cone finding.” For a circle, the answer is obvious. Here’s a circle in the xy-plane.
As you might guess, there are many cones that are possible. The apex of these cones lie on the z-axis. Here’s a sample of ten possible cones (out of infinitely many).
Here’s only a few of the cones, for easier visualization.
The circle case is easy, and obvious. What about ellipses, parabolas, and hyperbolas? Those cases are more interesting. I believe Hilbert’s book as a discussion on “cone finding” although I think he doesn’t call it that.
My own terminilogy: Cone-finding means finding all cones that can be sliced to produce a specific conic-curve. The cones in question have an apex each. For the circle, all the cone apexes lay on the z-axis, which is a line. That is, the set of all apexes is a curve, which I call the apex-curve. Every cone has its apex on the apex curve. “Cone finding” and “apex curve” are my own terms, and not official jargon of geometry.
Apex-curve for the ellipse. The green curve is our ellipse in the xy-plane, with it’s long-axis on the x-axis. The two red hyperbolas are in the xz-plane (extra red lines to help visualize). Every cone that can be sliced to make the green ellipse, has an apex on the red hyperbola. The red hyperbolas extend to infinity.
A sampling of the cones that make the ellipse.
That’s a lot of cones, so let’s only draw a quarter of them, since the rest are generated by mirror symmetries.
Parabola. The apex-curve of a parabola is another parabola. We start with the green parabola aligned to the x-axis in the xy-plane. The apex curve is the red parabola in the xz-plane.
Here’s a sampling of the cones.
That’s too many cones to understand, so here’s half of them.
Finally, the most complicated case, the hyperbola. The apex curve of a hyperbola is an ellipse. We start with the green hyperbola which is aligned to the x and y axes. The red ellipse is the apex curve in the xz-plane. Extra red lines to help visualization.
Here’s a sampling of some of the cones.
That’s kind of a mess, so here’s a quarter of the cones.
Okay that’s it. A fun project for myself, and I hope of some minor interest to others, both for the taste of how NURBS curves work, and some fun with conic curves.
Sincerely,
--Anthony Yan
P.S. Here my .3dm, grasshopper and python files. You’ll need to put TonyUntils.py into your directory for scripts.
C:\Users\MyUserName\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\Tony
where MyUserName is your user-name.
You can find TonyUtils.py in the “Rhino 8 Python” sub-directory.
I’m releasing this under the permissive MIT license.
Conics 2d (2.1.8) (Release).zip (13.2 MB)
P.P.S. For those of you who look very carefully at the pictures, you’ll realize that you can generate the apex curve of a conic in three steps:
(1) Align the conic-curve to the xy-axis. If the conic has reflection symmetry (circle, ellipse, hyperbola), then put the center at the origin. And align the conic so that it intersects the x-axis. For an ellipse, put the long-axis on th x-axis, and for a hyperbola have each branch intersect the x-axis. For a parabola, have it open towards the +x or -x axis. Where our conic intersects the x-axis, we will call those points the vertex or verticies of the conic.
(2) If I tell you a conic’s focii and vertices, then there is only one possible conic. (Not too hard to prove, but I won’t show the math here. It’s maybe a HW problem at the level of HS math.)
(3) Given a conic’s focii f1, f2, and vertices v1,v2, you can generate the apex curve by simply swapping the focii for the vertices, and drawing the new conic in the xz-plane.
Example: Suppose you have an ellipse with focii f1,f2, and verticies v1, and v2 as described above (aligned to the x-axis, in the xy-plane).
Make a new conic with focii g1,g2 where g1=v1, g2=v2 and vertices u1=f1 and u2=f2. This has to be a hyperbola. Draw this hyperbola in the xz-plane.
So you can chain all of these results together:
(a) Given a cone and a slicing plane.
(b) Slice the cone to get a conic curve
(c) Use spheres to find the focus or focii of the conic curve.
(d) Align the conic-curve and it’s focii to the x-axis in the xy-plane.
(e) “Swap” the vertices and focii of the conic, to get the apex curve in the xz-plane.
(f) Pick any point(s) on the apex curve, and draw cones.
For details on how this all works out, see Hilbert’s book.



























