A circle in perspective (don’t read if you hate math)

Posted on

Long time no Beep! Something has been gumming up the works here at Beepily. I think I’ve worked it loose though. In fact, I worked most of it out with a pencil!

Anyway.

I have been preoccupied with the question of how to draw a circular object in perspective. It seems to be common knowledge that a circle viewed from an angle looks like an ellipse. I’ve always believed that it would look pretty much like an ellipse, but was never quite confident that it would be exactly an ellipse.

You can sketch a circle in a square and then sketch a tilted square and draw a curve inside that, but that doesn’t prove that the proper curve to draw is truly elliptical.

There’s a treatment of this problem, by Andrejs Treibergs at the University of Utah, which has finally convinced me. I’m just going to summarize his approach here. There’s always the possibility that I’ll make a mistake, so be warned! About that. That I may make a mistake. Feel free also to be warned about anything you think may be important to be warned about, but you’ll have to get that warning somewhere else. I think I’ve given ample warning here already.

Down to business:

First we need to look at the setup. Let’s say we have an observer.  For here, I’m going to simplify this to a single eye.* Somewhere off in space, oriented in some direction, there’s a circularly-shaped object. There’s a planar surface for the drawing to go onto (following Treibergs, let’s call that the “drawing plane”). The only way to arrange this that makes sense is to put the drawing plane between the observer and the object.

Here, refer to my handy diagram.

Wait, wait, wait. That’s not as clear as G and I thought it was when we finished it. Let me try again.

Diagram of perspective

OK, how about this? There’s a perfectly good diagram on Treibergs’ page (in this section), and if mine has any errors in it, his likely doesn’t. What we’re looking at is a diagram that says that light travels in a straight line from a point on the object to the “eyepoint” (surprisingly enough, that’s the supposed location of the observer’s eye), and that we can intercept that straight line at whatever distance from the eye we put the canvas or “drawing plane.” If we put the image on the drawing plane exactly as it’s intercepted on the way to the eyepoint, then it will look exactly as though it comes from the object, as long as the observer’s eye sits exactly at the eyepoint.

What I want from this exercise is mathematical proof that the shape traced out on the drawing plane by the light intercepted on its way to the eye from the perimeter of the circle is an ellipse.

It’s convenient, since the eyepoint is where the rays of light end up (whether they’re directly from the object or from the image of the object on the drawing plane), to define that point as the origin (0,0,0).

We would be making things perversely hard for ourselves if we didn’t set the (x,y,z) axes up so that two of them form a plane parallel to the drawing plane.  If this plane is the x-z plane, then the drawing surface is defined by the equation y = d; d is the distance from the eyepoint to the nearest point on the drawing plane.

So far the setup is what we’d use for drawing any shape in perspective.  Moving down to the section on circles:

Treibergs points out that since it doesn’t really matter, to the physical system, which way we orient the x and z axes, for mathematical convenience we should rotate them around the y axis until the intersection of the plane the circle is in and the drawing plane is a “horizontal line;” i.e. a line along which v is constant.  We can rotate the canvas back the right way up after there’s a drawing on it.  It’s probably worth admitting here, for clarity, that I haven’t drawn my diagram taking this into consideration.  Just imagine the bike wheel is leaning back from the drawing plane but that we’ve oriented the x and z axes so there’s no side-to-side pivot on the wheel.

Call the point where the centre of the circle lies (x0, y0, z0), and call its radius r.

Then use the following mathy things:

1) The fact that u/d= x/y and v/d=z/y , which is demonstrated by finding similar triangles in the diagram.  This holds true for any point (u,v) at which the drawing plane intercepts a line from some point (x,y,z) in space to the eyepoint (0,0,0).  He sets d=1, which is fine because this can be 1 of any unit we make up. So the equations become:

x = uy     (1a)

and

z = vy      (1b)

2) The fact that the circle can be defined by the intersection of a sphere with the same centre point and radius as the circle and a plane passing through the centre of the sphere.  The equation of the plane is

(z-z0) = m(y-y0)     (2)

and the equation of the sphere is

(x-x0)2+(y-y0)2+(z-z0)2 = r2     (3)

He then proceeds to substitute ((1) and (2) into (3) to write (3) in terms of u, v, m, x0, y0, and z0 (which are all constants except u and v), and then multiplies it all out to make something rather long and messy.

3) The ugly duckling of a long and messy equation turns out to be a lovely swan of a quadratic equation in two variables, and order and elegance are restored to the universe. Also, it narrows the possible shapes traced by the allowed u and v values to the conic sections. This, in itself, shows that the curve we need is a basic mathematical curve, and not some tricky fudged thing with a different curve to the front than to the back. Which is actually quite a relief.

One could say we’re pretty much done at this point, because as long as we can see the whole object, and we’re not looking at it perfectly edge-on, we know it’s not a line or an empty set or a parabola or a hyperbola; it must be an ellipse.

4) However, he goes ahead and finds the sign of the discriminant of this equation, which tells us which type of conic section to draw. The way he writes his quadratic equation and discriminant mean the sign convention used to determine whether the solution is an ellipse or a hyperbola is the opposite to the way I’m used to looking at it, so I’m leaving the specifics of that out.

What the sign of the discriminant hinges on is the sign of

(1+m2)y02 - r2.

This is the same as asking whether the point at which the x = x0 line on the circle plane (z-z0) = m(y-y0) crosses the y=0 plane is further than the circle’s radius r from the centre of the circle (x0, y0, z0).  If the answer is “yes,” this is the same as saying that no part of the circle reaches the y=0 plane: all of the circle is ahead of the observer’s eye. If that is the case, the curve on the drawing plane is indeed an ellipse.

This leads, if I’m not confusing myself, to a new discovery for me: if we were to say the circle touched the y=0 plane, then the discriminant would be 0 and we’d have to draw a parabola; if the circle extended behind y=0 (for example, if the observer were standing inside a big circular pool or a circus ring) then the curve would be a hyperbola.

That, to me, is not intuitive! I have tried hovering my head over a big circular table, and leaning over a liquid nitrogen dewar with my eyes within the circle of the guard ring at the top (this must have appeared extremely strange behaviour in the context), and can just about believe it, as long as I make sure to remember not to cheat by looking down too steeply at the table (which takes the whole circle to points with y>0; i.e. “ahead” of my eye).

I hope this has cleared the blockage at the beep factory. I’m pretty sure I won’t be putting any explicit math in again for a little while.  The formatting alone is agonizing. I can’t guarantee this ellipse thing won’t resurface though.

If I’ve got anything wrong here, I’d be happy to hear about it.

*If you want to do a two-eyed observer with both eyes open, and you want things perfect, go ahead and do some sort of 3D-glasses thing with a slightly different image for each eye.  Just make sure his/her eyes are exactly the width apart that you calculated for and that she/he is standing perfectly still, in exactly the spot you calculated for.