This problem stems from a British Standard for staircases, of all things (BS 5395-1 2010, diagram B4 p.27), which prescribes the position of stairs when they turn a corner. I've tried to find an easy way to calculate the positions rather than use "pen and paper", but because it's based on ellipses, I can't find a way to create a good calculation method for it. I've abstracted the "real world" problem and would like ideas how best to approach it.


  • P1, P2 and P3 are three arbitrary points not in a straight line; (x1,y1) are the co-ordinates of P1; L1 and L2 are the line segments P1-P3 and P2-P3.
  • e is an ellipse drawn tangent to L1 at P1 and tangent to L2 at P2.
  • k is an arbitrary parameter required to fix one specific ellipse e out of the many ellipses that could be drawn - needed because the original problem only specifies 4 constraints for an ellipse, and an ellipse needs 5.
  • G is a number > 0 that is "small-ish" compared to the distance between P1 and P2 (in the real world problem G would be about 20% to 50% of the distance between P1 and P2). This condition ensures that the intersection (x2,y2) described below actually exists, and that the problem isn't pathological or degenerate.

The problem is to determine formulaically - ie not using approximations - the points (x1,y1) (x2,y2) etc constructed by this algorithm:

  1. Draw the points P1, P2, P3 and the line segments L1, L2.

  2. Draw an ellipse e that is tangent to L1 at P1 and tangent to L2 at P2. Because there may be an infinity of such ellipses (4 constraints, 5 required), this step requires us to create some convenient way to parameterise the problem with a 5th parameter "k" which can be varied to choose one unique ellipse out of all possible tangential ellipses for a given {P1, P2, P3}.

  3. Draw a circle radius G centre P1. Because of the "small-ish" limit on G, this circle will intersect the ellipse e at some point of its arc between P1 and P2. Call this point (x2,y2).

  4. Continue repeating step 3, at each iteration drawing a circle radius G centre (x(n),y(n)) and call the next intersection with the ellipse e, (x(n+1),y(n+1)), then a circle centre (x(n+1), y(n+1)) with intersection (x(n+2),y(n+2)), etc. Stop when we would go past P2. In the "real world" problem we will have constructed no more than 4, perhaps 5 points (x2,y2) through (x4 or x5, y4 or y5).

The "stop at P2" constraint means our solution doesn't need to consider any intersections on the "return arc" of the ellipse; and the smallness of G means that our circle at (say) (x3,y3) must always intersect the ellipse e at just two points: (x2,y2) which we already know, and (x4,y4) which is the point we want - it can't touch the "far side" of the ellipse or fail to touch it at all.

The problem is to pick a convenient parameterisation method ("k") and then, given arbitrary P1, p2, P3, G, k, determine the co-ordinates of all (xn,yn). I'd like to avoid "brute force" methods such as approximation techniques but I can't see how. Is there a "sensible" way to do this algebraically? How might I go about it?

Diagram for this problem

Update 1:

I solved the first part (I think) by using a property of tangents to an ellipse, namely that lines from either focus of an ellipse to a point on its perimeter, will make a constant angle with the tangent at that point. Switching that around, if I choose 0 <= α < 90 as an arbitrary angle, then a line at α to the tangent must pass through a focus of the ellipse, from both P1 and P2. I can therefore find my unique ellipse, which is the first part of the problem, this way:

  1. Construct the normals N1 and N2, passing through P1 and P2 (easy, as I have the direction of the tangents at both points).

  2. Pick an arbitrary angle 0 <= α < 90. This will be my parameter "k" above, the 5th parameter needed to identify a unique ellipse among all possible solutions.

  3. Rotate both normals around their respective points by (α). That is, rotate N1 using centre P1 and rotation = α, and rotate N2 using centre P2 and rotation = α. Identify the point these intersect as F1.

  4. Do the same again, but this time rotating both normal by (-α). Again the normals will intersect and call this point F2.

  5. The unique ellipse for (P1, P2, L1, L2, α) is an ellipse with foci (F1) and (F2). Its eccentricity can be found by usual ellipse properties as we know both foci and a point on the perimeter (ie the distance F1-P1-F2 etc). Its axes can be found by constructing the line F1-F2 and its bisector, and so on.

Note, I used the normal not the tangent because then the foci are at +/- α, not α and (180-α), which is simpler :)

Also, the family of solutions can be found by varying α, and I think that this must generate all solutions since any ellipse that is a solution must by definition have lines from its foci to P1 and P2 that are at some identical angle (α) to L1 and L2.

Now just to solve the intersection of the circles and the ellipses.

So far, is this correct? Is this necessary, or n & sufficient?

diagram of this update, showing constructions

(this bit struck out as incorrect, see comment below)

  • $\begingroup$ The simplest way to pick a unique ellipse would be to choose the one with center $P_3 + (P_1 - P_3) + (P_2 - P_3)$. However, maybe it would be more aesthetic to choose the one that's closest to circular, which this doesn't do. $\endgroup$
    – user856
    Oct 5, 2015 at 11:40
  • $\begingroup$ As for finding the intersection points, see this previous question: math.stackexchange.com/q/655619/856 $\endgroup$
    – user856
    Oct 5, 2015 at 11:42
  • $\begingroup$ @Rahul - thanks, I will look at that answer. Circular isn't an issue and may even be a disadvantage - in the real world case, G has a "no less than.." criterion. An ellipse creates a longer arc, making it possible to choose a slightly larger G and still have the same number of intersections before P2, which will often be helpful. For a similar reason I'd like to avoid choosing one ellipse only, and find a parameter to get all ellipses meeting the conditions, so I can vary the parameter and see what ellipses result (of course some will be esoteric but that's okay). Any help with that? :) $\endgroup$
    – Stilez
    Oct 5, 2015 at 14:42
  • $\begingroup$ Sure: math.stackexchange.com/a/109927/856 $\endgroup$
    – user856
    Oct 5, 2015 at 16:53
  • $\begingroup$ Thanks! I was about to post that I think I've solved my own problem (partly anyway) - updated above. Used the fact that the internal angle from a focus to a point on the perimeter has a constant angle with the tangent. So I can parameterise all possible solutions by choosing an angle 0 <= α < 90 and rotating each normal clockwise (and calculating where they now intersect) and then counter-clockwise (ditto). Any solution must have these two points as its focus, and there is an infinity of such ellipses, one for each choice of α. Necessary? Or necessary and sufficient? $\endgroup$
    – Stilez
    Oct 5, 2015 at 18:07

2 Answers 2


I came back to this a year later, with a different approach and help from the answers on this question. Essentially what I had tried to do, was solve and plot the equation of the ellipse itself, which on the face of things is what the standard requires. What I did second time around was use affine transforms on the unit circle. Quick summary:

The transforms I looked at, preserve things like tangency, and transforms ellipses (including circlers) into ellipses, and straight lines into straight lines. So I looked at two sets of transforms:

  • the transform to send points (x,y) on a unit circle to points (x,y) on an ellipse oriented at 45 degrees, which touched and had as tangents the lines x=1 and y=1. (There's a whole family of such ellipses which could meet this condition, so of necessity one must introduce an arbitrary parameter to select from this family, one specific ellipse.) I could then calculate trivially the co-ordinates, angles, and anything else for points on the unit circle and derive from them, the "equivalent" points for a suitably tangential ellipse which I could then plot and work with.
  • a transform which maps the lines x=1, y=1 to the lines in my problem that must be tangents to the solution ellipse.

These were both straightforward. I then started with the points on a unit circle, and an arbitrary parameter "p", and transformed the points to points on an ellipse tangent to x=1,y=1. I then ytransformed these points further, to obtain points on an ellipse which was tangent to the lines in my actual problem. Had I needed an actual formula, I could have obtained it much the same way, by tracking the old -> new conic obtained in these two steps and the new conic equation resulting.

Admittedly it can be done faster and more strightforwardly in other ways as answers to this and other questions showed, but I lacked the skill and knowledge to do so.


Here's a geometric way to parameterize your ellipses. Let $V$ be the midpoint of $P_1P_2$ and $Q$ the midpoint of $P_3V$. Choose another point $P$ of the ellipse at will on $QV$: then the center $C$ of the ellipse lies on line $P_3V$ and $$ CV={PV^2\over P_3V-2PV}. $$ Given $P$, the ellipse is uniquely determined, because we have its center and three points ($P_1$, $P_2$ and $P$). So $P$ (or the length $PV$) can serve as a parameter to generate all possible ellipses.

This construction is based on the following property (adapted from: Drew, Conic Sections, Prop. XVIII p. 48):

If from an external point $P_3$ a pair of tangents $P_3P_1$, $P_3P_2$ be drawn to an ellipse of centre $C$, and $CP_3$ be joined meeting $P_1P_2$ in $V$ and the ellipse in $P$; then $P_1P_2$ will be bisected in $V$ and $CP$ will be a mean proportional to $CV$ and $CP_3$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.