Programming contests

Andy Poe's Faculty Seminar, June 7, 2018

June 7, 2018 1:00 PM – June 7, 2018 5:00 PM

Elliptical Orbit

The known world, like all planets, orbits its sun in an elliptical orbit with the sun as one of its foci.

An ellipse (or, informally, an oval) is a shape such that every point on the ellipse has the same sum of distances to two fixed points called foci. The two foci are allowed to be the same point, in which case the ellipse is a circle. An ellipse can be expressed by the equation x2/a2 + y2/b2 = 1, where a ≥ b > 0. The two foci are located at (f,0) and (–f,0) where f = √(a2 – b2). The (constant) sum of the distances from each point on the ellipse to the foci is s = 2a.

Imagine that the sun is located at (f,0) and that the known world begins its orbit at the point (a,0). Kepler's Law of Equal Area specifies that the planet always sweeps the same area, measured from the sun, in the same amount of time, no matter where it is in its orbit. Thus, when the planet is nearer its sun, it must sweep a larger angle (centered at the sun) than when it is farther from its sun. Given the specification of the ellipse and a number of equal intervals of the orbit, you are to compute the angle swept in each interval.

Input Specification

Each input case consists of two unsigned floating-point numbers representing a and b in the ellipse equation and an unsigned integer, n, representing the number of equal time intervals in which we are dividing the orbit. The three numbers are separated by one space and the case is terminated by <EOLN>. “0<EOLN>” follows the last case. It is not to be processed; it simply specifies the end of input.

Output Specification

The output cases are to be processed in the same order as the input cases. Each case begins “Case c: The angles are<EOLN>” where c is the case number. Then follows a list of n – 1 angles, each rounded to the nearest second, formatted as shown below, and followed by <EOLN>. The first angle is the angle swept by the planet after 1/n of the orbital time. The second angle is the (total) angle swept by the planet after 2/n of the orbital time. And so on, up to the angle representing (n – 1)/n of the orbital time. An extra <EOLN> should follow each case.

Sample Input

  1. 10 5 4
  2. 10 9 5
  3. 0
download as text file

Output for Sample Input

  1. Case 1: The angles are
  2. 165 deg 20 min 30 sec
  3. 180 deg 0 min 0 sec
  4. 194 deg 39 min 30 sec
  5. Case 2: The angles are
  6. 121 deg 48 min 30 sec
  7. 163 deg 58 min 20 sec
  8. 196 deg 1 min 40 sec
  9. 238 deg 11 min 30 sec
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019