Star trail in terminal.
Using:
-x='(1+0.05*i)*(x*cos(i*pi/100)-y*sin(i*pi/100))' -y='(1+0.01*i)*(x*sin(i*pi/100)+y*cos(i*pi/100))' -l 0 -n 500
Basically, you stand on a north pole of a planet with no axial tilt and counter-clockwise rotation like Earth, and no movements in this universe but only the planetary rotation. You look up straight at night sky with a camera, long-exposing for \pi/2.
This is a simple simulation and it's not meant to be accurate. You can read this blog post which is about the back story and thoughts or watch this video to see how it's animated.
Contents
- C99 and POSIX.1-2008 supported compiler
- POSIX-compliant system
- ncurses
- (optional) GNU libmatheval for evaluators
Simply do the following to install under /usr/local
,
make install
Or you can use PREFIX
to choose the installation location, for example
make PREFIX=$HOME/.local
To uninstall, use uninstall
target.
name | value |
---|---|
matheval |
for evaluators, 1 (default) to enable |
This program simulates a very simple universe, stars and a planet which observer can stand on. Nothing moves but the planet's rotation, which is counter-clockwise like Earth in the perspective. There is no axial tilt unlike Earth or any actual planets, this is to simplify when you stand at north pole, every star will be long-exposed as a perfect circle.
new_star` function generates -n #
stars, each star has
angle in [0, 2\pi)
The angle and distance are observed on the viewport.
distance in [0, 1]
If distance is 1, it will be converted into r.
color is randomly chosen from the available colors.
expose
is the heart of this program, it has four processes:
- calculating the new coordinate
- applying evaluators
- applying zooming factors
- converting coordinate into terminal position
With variables:
- x, y
- The coordinate
- a, d
- The star's initial angle and distance
- i
- The ordinal number of current iteration
- s
The stepping value for rotating angle,
\tan(\frac{SCALE_X}{CENTER_X})
- r
The longest straight line can be drawn from the center of terminal window, in other words, from center to any corner. It's chosen this way for a possibility to fill up window with rings of trails.
\sqrt{\left(\frac{SCREEN_H}{2}\right)^2 + \left(\frac{SCREEN_W \cdot SCALE_X}{2}\right)^2}
The first process calculates the new coordinate on the viewport after one iteration of rotation.
x = d \cdot \cos(a + i \cdot s)
y = d \cdot \sin(a + i \cdot s)
If -R
is used, they will always be the initial coordinate.
x = d \cdot \cos(a)
y = d \cdot \sin(a)
These options enable you mathematical functions to manipulate star's coordinate. Both are functions of seven variables and many functions and constants are supported.
x = f(x, y, a, d, i, s, r)
y = f(x, y, a, d, i, s, r)
Basically, the first and third processes can be completely replaced by the
evaluators with -R
and -Z
to disable the two processes.
After the evaluators, the coordinate is manipulated as if viewport is zoomed,
x = x (1 + i \cdot factor_x)
y = y (1 + i \cdot factor_y)
This process can be turned off by -Z
option.
The coordinate is converted into terminal position using
x & = & CENTER_X & + & r & \cdot & x & \cdot & SCALE_X \\ y & = & CENTER_Y & - & r & \cdot & y
key | action |
---|---|
space |
resume from pause (interval<0) / skip (large interval) |
c |
clear screen before next iteration |
q |
quit |
The contents in this repository have been place into public domain via Unlicense.