Suppose that at some initial time t=t1 Jupiter had occupied that midnight position, and that it returned to midnight at t=t2. The period of Jupiter is NOT the elapsed time t2–t1, because all observations are from our own moving Earth, whose orbital period is a big factor here.
(E.g. if Jupiter did not move at all, like a distant star, the elapsed time would be one exactly one Earth year, the time needed for the Sun and for midnight to return to the same positions relative to distant stars.)
You may visualize the motion of both planets around the Sun using the face of a giant clock: the big hand points at Earth, and the small hand, which moves more slowly, points at Jupiter. At t=t1 the clock's time is noon since both hands point in the same direction.
If TE and TJ are the orbital periods of Earth and Jupiter, when a time t has elapsed from the starting position, Earth (large pointer) has rotated in its orbit an angle (t/TE)360° , and Jupiter (small pointer) has rotated (t/TJ)360°. The Earth rotates faster, so the angle between the lines from the Sun to the planets (the clock's "pointers") is
(T/TE)360° ̵ (T/TJ)360°
At some time t the Earth overtakes Jupiter again, making that angle is 360° and placing Jupiter again at midnight (a different constellation is behind it, however). At that time
(t/TE)360° ̵ (t/TJ)360° = 360°
(t/TE) ̵ (t/TJ) = 360° = 1
The time it takes Jupiter to return to midnight (or to any other position relative to the Sun) is its synodic period TsJ and it satisfies
1 /TE ̵ 1 /TJ = 1 / TsJ
If you observe TsJ and know the Earth's orbital period TE, you can derive the orbital period TJ of Jupiter, a matter of about 11.86 years.
Now to the distances RE and RJ. From observations such as those available to Kepler and Copernicus, one could only derive relative distances, ratios such as
(RJ / RE)
which is the distance from the Sun to Jupiter in units of the Earth's distance or "the astronomical unit." To obtain the distance in conventional units of distance, e.g. kilometers or miles, other methods are needed. That task is much more difficult and is described in The Scale of the Solar System.
Start again with Jupiter in its midnight position J1, while Earth is at E1. Let us call here the Sun-Earth-Jupiter line "The Main Axis" for short. The drawing at the far right assumes a view from high up on the northern side of the plane of the ecliptic, so both planets orbit counter-clockwise (CCW).
Earth orbits the Sun faster than Jupiter and overtakes it, so after (say) 2 months Earth has advanced to E2 while Jupiter has only advanced to J2, a smaller distance. The line of sight Earth-Jupiter has therefore rotated clockwise and Jupiter is in fact undergoing retrograde motion.
After 3 months (a quarter orbit) Earth has reached its greatest distance from the main axis and begins to move closer to it again, while Jupiter continues its slow advance as before. Therefore a time T0 will come when Earth at E3 and Jupiter at J3 will be at the same distance from the "main axis", and observers at Earth will see Jupiter in front of the same distant stars as were behind it when it passed midnight (though, because the Sun is now in a different direction, they are no longer at midnight).
At this time, Earth has gone around its orbit a total of
and if RE is its distance from the Sun, its distance from the main axis is
RE sin(T0/TE) 360°
while the angle covered by Jupiter in its orbit is
and its distance from the main axis is
RJ sin(T0/TJ) 360°
The two distances are equal, because the Earth-Jupiter line is parallel to the main axis. Therefore
RE sin(T0/TE) 360°
= RJ sin(T0/TJ) 360°
We already have TE and TJ, and if the value T0 is observed, we can deduce RJ/RE which is about 5.2. Kepler may have done the calculation more accurately, but this simple version gives the idea.
The Inner Planets
The planets Venus and Mercury orbit is inside the orbit of Earth, but a similar method may be used for them, too. However, the "reference axis" most convenient here is the line from Earth to the planet when its position in the sky is furthest from the Sun or at "maximum elongation." It happens in two positions of the orbit--in one, the planet is visible on the night sky before sunrise, and the other, after sunset. At maximum elongation the planet is at about as bright as it gets, and of course, it never passes midnight.
Assume we try to derive the orbital period TVVenus, and the time which has passed since maximum elongation (say, on the evening side) is t. Venus, moving faster than Earth, has covered an angle (t/TV)360° and Earth an angle (t/TE)360°. The angular separation between the lines connecting them to the Sun is
(T/TV)360° ̵ (T/TE)360°
At time TsV (synodic period of Venus) the separation has reached 360°, a full circle, which means Venus has again reached maximum elongation on the evening side (following sunset). As before, we find
1 /TV ̵ 1 /TE =1 / TsV
and from measuring that time, we get the true orbital period of Venus TV, about 225 days.
The greatest elongation of the planet is about α = 47°. In "astronomical units" with the Earth-Sun distance equal to 1,
sin α = sin 47° = RV/1 = 0.731
This gives the distance of Venus as 0.731 AU (assuming circular orbits, constant speed and all orbits in the same plane).
Kepler thus knew the orbital periods and relative distances from the Sun for all the planets visible to him. Why then did he wait until 1620 to announce his third law, about 10 years after the other two?
I do not know and can only guess. It could be that he stuck to his older mystical interpretation of planetary distances, connected to the 5 Platonic solids--the only 5 solid figures whose faces are identical equilateral polygons and which fit snugly inside (or outside) a sphere, the only perfectly symmetric polyhedrons in 3-dimensional space. These were the tetrahedron (4 triangles, a 3-sided pyramid), cube (6 squares), octahedron (8 triangles), dodecahedron (12 pentagons) and icosahedron (20 triangles).
If each planetary orbit defined a sphere, the space between the spheres of Mercury and Venus enclosed a tetrahedron, between Venus and Earth a cube, and so on.
A closer examination showed that such a "law" gave a rather poor fit. By 1620, however, logarithms had been discovered and Kepler embraced them with enthusiasm. By plotting log T against log R, the 3/2 power dependence was clearly seen.