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.