Notwen wants to study the kinematics of bodies thrown from big heights in a uniform gravitational field but unfortunately he doesn't have the technical possibility to go to sufficiently high places and observe the objects while falling. But who doesn't want to see advances in science so... Let's help Notwen build a gravity simulator!
Physical Background
An object dropped from a height \$h\$ (without initial velocity) in a uniform gravitational field, neglecting atmospheric effects such as drag or wind gains velocity and speeds up towards the ground with time. This "rate of change" of velocity in a unit of time is called gravitational acceleration. Near the surface of Earth, it is approximately equal to \$g\approx9.8\frac{m}{s^2}\$, but for the purposes of this challenge we will use the value \$10\frac{m}{s^2}\$, meaning that in a single second, an object increases its velocity by about \$10 \frac{m}{s}\$. Consider having a height \$h\$, which is a multiple of \$100m\$ and imagine dividing that height into equal intervals, each \$100\$ meters long. Notwen wants to measure how long it takes for the object to fall through each of those intervals, so that's what we aim to compute as well. Modern kinematics – skipping technicalities – tells us that: $$\Delta h_k=v_kt_k+\dfrac{1}{2}gt_k^2$$ where \$\Delta h_k\equiv\Delta h=100m\$ for all values of \$k\$ in our case, \$v_k\$ is the initial velocity at the beginning of our \$k^\text{th}\$ interval and \$t_k\$ is the duration of the \$k^\text{th}\$ time interval (for reference, indexing starts at \$0\$ with \$v_0=0\$). We also know that \$v_k\$ has the following expression: $$v_k=\sqrt{2g(\Delta h_0+\Delta h_1+\cdots+\Delta h_{k-1})}=\sqrt{2gk\Delta h}$$ Numerically, we get \$v_k=\sqrt{2000k}\frac{m}{s}\$ and plugging into the first equation and solving for \$t_k\$ gives $$\color{red}{\boxed{t_k=2\sqrt{5}\left(\sqrt{k+1}-\sqrt{k}\right)s}}\tag{*}$$ So the object travels the first interval (\$k=0\$) in \$4.4721s\$, the second interval (\$k=1\$) in \$1.8524s\$ and so on (pastebin with more values).
The challenge
Input: The height \$h\$ from which the object is thrown as either: a positive integer multiple of \$100\$, \$h\$ or the number of intervals \$N=\frac{h}{100}\$ (so either \$700\$ or \$7\$ would mean that \$h=700m\$) – which one is up to you.
Output: An ASCII art animation of a falling object, dropped from a height \$h\$ (details below).
The structure of an output frame must be as follows:
- \$N\$ newlines preceding the "ground", represented by at least one non-whitespace character (e.g.
@
). At least one of the characters of the ground must lie on the vertical that the object falls on. - Another non-whitespace character representing the object (e.g.
X
), other than the one you chose for the ground. - Optionally, a character at the beginning of each line representing the vertical axis or the wall made on \$N\$ lines. Any amount of leading and trailing spaces are fine as long as they are consistent between frames, as well as any amount of spaces between the wall and the object. Examples of valid frames include1 (for \$h=700m\$ or \$N=7\$):
| X > | @ > A | > | or or or > | O > | > | > @@@ ^ ----- &&&
The object must start on the first line of the first frame, then after \$t_0\approx 4.47s\$ the output should be flushed and your program should display the object on the same vertical but on the next line in the second frame; then after \$t_1\approx 1.85s\$ the output should be flushed again and your program should display the object on the same vertical but on the next line in the third frame and so on, until the object reaches the line right above the ground. Example:
Rules
- The output should be some text written to an interactive (flushable) console, a GIF, a separate file for each frame or some other reasonable technique of output.
- Each frame should completely overwrite the last frame and be in the same location.
- You can assume that the time required for the compiler / interpreter to output the text is negligible and the minimum precision permitted for computing the square roots is to 2 decimal places.
- You can take input and provide output through any standard method, while taking note that these loopholes are forbidden by default. This is code-golf, so try to complete the task in the least bytes you can manage in your language of choice.
1: I'm lenient about what constitutes a valid frame because I want to allow whatever suits your solution best and I'm not trying to add superfluous stuff to the challenge. If anything is unclear, ask in the comments.