Time dilation clock experiment: what would happen if the clock were flipped 90 degrees? I have seen and understood the classical thought experiment where you imagine a "light clock" sending a light ray between two mirrors while moving in a perpendicular direction to the lights direction in the reference frame of the clock, as shown here:

What I don't understand is that the formula for an observers perceived time, $\Delta t'$, of the clock is derived from the Pythagorean theorem which only works because the light is being reflected in a direction perpendicular to the direction of the velocity of the clock (from the clock's point of view). If the clock reflected the light in the same direction as it was itself moving, that is in the animation above the clock would be flipped 90 degrees "laying down", then it would still be a clock because it would still have a fixed period but I don't see how one would derive the same result for how a bystander perceives the clock:  
$$\Delta t' = \dfrac{\Delta t}{\sqrt{1-(v/c)^2}}$$
I am asking this because in the example I've seen of length contraction, the clock was moving in the same direction as the light was being reflected, but in the derivation of the equation of the contraction effect they still used the formula for time dilation, which was derived when the clock was "standing" as in the animation above.
 A: First:    An observer traveling with both a vertical and a horizontal clock must see them tick at the same rate --- otherwise he'd know he was moving.  
Second:  The traveling observer and a "stationary" observer must agree about how many times each clock ticks during the time it takes the traveler to go from (say) Mars to Jupiter, because they can both simply watch the clocks and count their ticks.  Therefore, since the traveling observer says they both tick an equal number of times, so must the "stationary" observer.  
Putting the first and second observations together, everyone agrees that the horizontal and vertical clocks tick at the same rate.  
Now if you take the vertical clock away, there's no reason for the tick-rate of the horizontal clock to change.  Thus the horizontal clock must tick at the same rate as the vertical, even if the vertical clock is not there.
So:  Use the vertical clock to calculate the time dilation.   Recognize that the same time dilation must apply to the horizontal clock, whether or  not there's actually a vertical clock on board.  Now (all of this from the viewpoint of the "stationary" observer) you know the horizontal clock's tick-rate.  You also know how fast the clock is moving, and you know the speed of light, so you can figure out the length of the light-beam's round-trip journey, and therefore can figure out the  length of the horizontal clock.
A: The reason why a transverse clock is typically used in teaching SR is that the associated maths takes a simpler form in such a case.
As other answers have shown, you can derive the same result from considering a clock oriented along the direction of motion. In some respects this provides more insight into the nature of time dilation as it more explicitly involves a consideration of the relativity of simultaneity.
Specifically, the clock in the moving frame ticks unevenly, as the path length of the light on the outbound tick is longer than the path for the return tick. If you consider that for a moment you will see that while the overall time for both ticks is time dilated by the familiar formula, the outbound tick is time dilated by another amount entirely and the return tick is actually time contracted.
This example is a reminder that the time dilation formula is applicable only to the interval of time between two events that occur in one place.
A more interesting result is the case of two moving back-to-back longitudinal light clocks which send off light in each direction from a common centre. Here, the outbound tick of the clock which sends out light in the direction of motion of the clocks is longer than the outbound tick of the other clock, while the reverse is true of their return clicks. Neither time dilation or length contraction alone can explain this- what it illustrates is the relativity of simultaneity. Where you have two moving reference frames, a plane of constant time in one frame is a sloping slice through time in the frame through which it is moving, the slope being upwards in the direction of motion. Both time dilation and length contraction follow from that rotation of the planes of constant time between the two reference frames.
A: @WillO gives a good conceptual explanation. For completeness it's possible to show that the same time dilation results in either case.
A horizontal clock would be moving in the direction of its length, so we need to worry about length contraction as well.  According to the stationary observer, the horizontal clock is $\ell^\prime = \frac{1}{\gamma}\ell$ long, and
$$ \gamma = \frac{1}{\sqrt{1-\left( \frac{v}{c}\right)^2}} $$
is the Lorentz factor.
Stationary Clock
It takes the light $\Delta t = 2\ell / c$ to make a round trip for the stationary clock. Another way to put it is that the total round trip distance is
$$ c\, \Delta t = 2 \ell .$$
Moving Clock
For the moving clock break the motion of the light up into two parts: the outgoing part (before reflection) and the returning part (after reflection).
outgoing time
For the outgoing part the distance traveled by the light in time $\Delta {t_\mathrm{o}}^\prime$ is
$$c \, \Delta {t_\mathrm{o}}^\prime = \ell^\prime + v\,\Delta {t_\mathrm{o}}^\prime .$$
The light traveled speed $c$ for time $\Delta {t_\mathrm{o}}^\prime$.  The light needed to move the length of the clock plus the amount the far end moved while the light was in transit.  Anticipating the end result, rewrite this as
$$ c \, \Delta {t_\mathrm{o}}^\prime = \frac{\ell^\prime}{1-\frac{v}{c}} .$$
returning time
For the returning part the distance traveled by the light in time $\Delta {t_\mathrm{r}}^\prime$ is
$$c \, \Delta {t_\mathrm{r}}^\prime = \ell^\prime - v\,\Delta {t_\mathrm{r}}^\prime .$$
The light traveled speed $c$ for time $\Delta {t_\mathrm{r}}^\prime$. This time the light needed to move less than the length of the clock, because the front of the clock moved towards the light while it was in transit.  Or
$$ c \, \Delta {t_\mathrm{r}}^\prime = \frac{\ell^\prime}{1+\frac{v}{c}} .$$
total time
The total distance for the light to travel out and back is
$$ c\,\Delta t^\prime = c\,\Delta {t_\mathrm{o}}^\prime + c\,\Delta {t_\mathrm{r}}^\prime
 = \frac{\ell^\prime}{1-\frac{v}{c}} + \frac{\ell^\prime}{1+\frac{v}{c}} $$
$$ = \ell^\prime \left( \frac{1+\frac{v}{c}}{\left(1-\frac{v}{c}\right)\left(1+\frac{v}{c}\right)} + \frac{1-\frac{v}{c}}{\left(1-\frac{v}{c}\right)\left(1+\frac{v}{c}\right)} \right)$$
$$ = \frac{2\, \ell^\prime}{1-\left(\frac{v}{c}\right)^2} $$
or 
$$ c\,\Delta t^\prime = 2\, \gamma^2\, \ell^\prime.$$
Putting together the length contraction and the two time results gives the expected
$$\Delta t^\prime = \gamma\, \Delta t $$
A: The light clock thought experiment you are describing is a one-dimensional experiment: On the left there is an observer, on the right there is the observed object moving horizontally = in x direction. The vertical dimension has been added for measuring purposes only - with a light ray traveling up and down.
By consequence, if you "lay down" the mirror system on the right side, the experimental configuration does not change. The observed object is still traveling in horizontal x direction. The only difference is that the travel of the horizontal light ray can no longer be compared directly with the observer's vertical light ray on the left. This configuration is less clear, but it is still the same process: an object receding horizontally from the observer in x direction.
Length contraction is a corollary of time dilation, that implies that with the light clock thought experiment you can also derive length contraction.
A: Any two events in the "moving" frame (the train) that occur in the same place and are separated by some time $ \Delta t $, as measured from that frame, will be separated by a longer time $ \Delta t^\prime = \gamma \Delta t $ when seen from the "stationary" frame (the train station). It's important that the events happen in the same place (e.g., light being emitted by a source and then arriving back at that source (after being reflected)) or at least in the same plane that's orthogonal to the direction of motion; otherwise, the calculation of time dilation will be confounded by differences in simultaneity between the two frames.
Clearly, the "longitudinal light clock" (rather than the more traditional "transverse light clock"), as some call it, in your example will work just fine. And the math can be very simple. I'll use similar conventions as Paul T.'s answer, so $ \Delta t_o $ is the outbound time and $ \Delta t_r $ is the return time. And I'll assume that the outbound light beam travels in the direction of the train's motion toward the mirror in the front part of the train.
Remember that $ \ell^\prime = \frac \ell\gamma $ due to length contraction and that $ \gamma = \frac{1}{\sqrt{1 - \frac{v^2}{c^2}}} $.
So from the moving frame, the time it takes the light to travel to the mirror and back is
\begin{align}
\Delta t & = \Delta t_o + \Delta t_r = \frac{\ell}{c} + \frac{\ell}{c} \\
& = \frac{2\ell}{c}.
\end{align}
Now since the stationary observer sees the train moving at $v$ and the outbound light moving in the same direction at $c$, he sees the light moving relative to the train at $c - v$ and thus traversing the distance $\ell^\prime$ at that speed. He then sees the returning light traverse that same distance at $ c + v $ (again, relative to the train). Therefore, the time it takes the light to travel to the mirror and back from his frame is
\begin{align}
\Delta t^\prime & = \Delta{t_o}^\prime + \Delta{t_r}^\prime = \frac{\ell^\prime}{c - v} + \frac{\ell^\prime}{c + v} \\
& = \frac{\ell^\prime\left(c + v\right)}{\left(c - v\right)\left(c + v\right)} + \frac{\ell^\prime\left(c - v\right)}{\left(c - v\right)\left(c + v\right)} \\
& = \frac{2\ell^\prime c}{c^2 - v^2} = \frac{2\ell^\prime}{c\left(1 - \frac{v^2}{c^2}\right)} \\
& = \frac{2\ell^\prime \gamma^2}{c} = \frac{2\gamma^2}{c} \frac \ell\gamma = \frac{2\ell\gamma}{c} \\
& = \gamma\Delta t.
\end{align}
A: *

*The Bondi k-calculus (an algebra-based method) develops the basic ideas of special-relativity in the $tx$-plane (without using the transverse direction).
This approach is presented in his book “Relativity and Common Sense” (1962, 1964). In addition, Bondi presented “E=mc2: Thinking Relativity Through”, a series of ten lectures on BBC TV running from Oct 5 to Dec 7, 1963.
(Read more at my contributed article to a blog at https://www.physicsforums.com/insights/relativity-using-bondi-k-calculus/ )

I have used it to develop the "longitudinal light clock" without appealing to the standard textbook "transverse light clock". In particular, I draw the light signals in the longitudinal light clock to form the "light-clock diamonds" (the "causal diamond" between consecutive tick events).  All light-clock diamonds for all inertial observers have equal area since the Lorentz boost transformation has determinant one.
This is developed using the Bondi k-calculus in my article:
Relativity on rotated graph paper, AmJPhy 84, 344 (2016); https://doi.org/10.1119/1.4943251 .
An early draft is at https://arxiv.org/abs/1111.7254 .
Rather than use "time-dilation" from the transverse clock,
I use the Principle of Relativity in the $tx$-plane.
The key figure (using $v=(3/5)c$) is

Once the light-clock diamond size is established (using the Bondi k-calculus in the above), the spacelike-diagonal of the light-clock diamond determines
the reflection events on the mirror worldlines of the longitudinal light-clock. So, draw through those
events parallels to the timelike diagonal (the observer's worldline). This shows length-contraction
as viewed in the lab frame. (The construction can be shown to be symmetric between the observers.)


*

*I have a different approach (that doesn't use the Bondi $k$-calculus directly) which appears in my recent contributed chapter
Introducing relativity on rotated graph paper
Ch 7 in
Teaching Einsteinian Physics in Schools
Kersting and Blair, Routledge 2021, https://doi.org/10.4324/9781003161721
I will describe it below.
You can play with the ideas in this visualization:
https://www.geogebra.org/m/HYD7hB9v#material/UBXdQaz4 (make sure BOB's diamonds are shown)

The key idea is that the diamond size is determined by the Principle of Relativity. (The diamond shape is determined by the Speed of Light Principle and the velocity of the observer.)
The two observers perform the same experiment
and should expect the same results:
2 seconds after they meet, send a light signal to the other.
Assuming absolute time and absolute space fails to satisfy the principle,
but the third configuration works.
Using $v=(3/5)c$... and assuming the Speed of Light Principle.. we have the shape of Bob's diamonds... but what is the correct size?
Assuming absolute time (so that the heights of the diamonds are equal),
Alice (red) receives Bob's signal at 3.2, whereas Bob (blue) receives Alice's at 5.
Bob's ticks need to be scaled up from this size.
This hints that there is time-dilation... but by how much?

Assuming absolute space (so the lengths of the cross-sections of the light-clocks are equal),
Alice (red) receives Bob's signal at 5, whereas Bob (blue) receives Alice's at 3.2. 
Bob's ticks need to be scaled down from this size.
This hints that there is length-contraction... but by how much?

By playing around (taking a hint from the geometric mean?),
we get agreement with the Principle of Relativity by each receiving the other signal at 4 ticks.



The ratio $(4\mbox{ ticks})/(2\mbox{ ticks})$ is the Doppler factor $k=2$ for $v=(3/5)c$,
where we have used the Principle of Relativity and the Speed of Light Principle...

...and, as a consequence, we now know the factor for time-dilation and length-contraction.
Try it for $v=(4/5)c$.

https://www.geogebra.org/m/kvfsq664 (updated)... make sure BOB's diamonds are shown
By the way, we find that the areas of Alice's clock diamonds are equal to Bob's clock diamonds. It turns out that the area of a causal diamond (in units of clock-diamonds) is equal to the square-interval between the corners of its diagonal.

For more information, consult my article and chapter above.
See also
 https://www.physicsforums.com/insights/spacetime-diagrams-light-clocks/
 https://www.physicsforums.com/insights/relativity-rotated-graph-paper/
A: Does no one see the issue that both the person on the ship and the one outside the ship can't  see light moving at a constant rate at the same time for the horizontal clock? If the person inside the ship sees light moving at a constant speed, then the person outside would see light traveling faster when light is moving toward the front and slower towards the back. If the person outside sees light moving at a constant speed, then the person inside would see light moving slower going towards the front and faster towards the back. They would both, however, calculate the same average speed of light.
