|
| 1 | + |
| 2 | +[](https://github.com/marketplace/actions/arduino_ci) |
| 3 | +[](https://github.com/RobTillaart/relativity/blob/master/LICENSE) |
| 4 | +[](https://github.com/RobTillaart/relativity/releases) |
| 5 | + |
| 6 | + |
| 7 | +# relativity |
| 8 | + |
| 9 | +Arduino library with relativity functions. |
| 10 | + |
| 11 | + |
| 12 | +## Description |
| 13 | + |
| 14 | +This experimental library implements a number of functions that give indication of the time dilation etc due to relativistic speed. |
| 15 | + |
| 16 | +Goal: Educational purposes or when one puts a cubesat into space :) |
| 17 | + |
| 18 | + |
| 19 | +## Interface |
| 20 | + |
| 21 | +- **relativity()** constructor |
| 22 | +- **double getC()** returns speed of light |
| 23 | +- **double getG()** returns gravitational constant |
| 24 | +- **double factor(double speed)** returns sqrt(1-v2/c2) |
| 25 | +- **double gamma(double speed)** returns 1/sqrt(1-v2/c2) |
| 26 | +- **double relativeTime(double time, double speed)** returns the relative time for given time and speed. |
| 27 | +- **double relativeLength(double length, double speed)** returns the relative length for given length and speed. |
| 28 | +- **double relativeMass(double mass, double speed)** returns the relative mass for given mass and speed. |
| 29 | +- **double EnergyMass(double mass, double speed)** returns the energyMass for given mass and speed. Think E = mc^2. |
| 30 | + |
| 31 | + |
| 32 | +### Caching variants |
| 33 | + |
| 34 | +These functions are the same however the math to calculate a given factor and gamma is done only once and cached. So these function will perform a bit better, especially if floating point is slow. |
| 35 | + |
| 36 | +- **void setSpeed(double speed = 0)** set the speed once and calculate the factor and gamma to minimize math for next functions. Think caching. |
| 37 | +- **double getSpeed()** returns speed set. |
| 38 | +- **double getFactor()** returns factor for speed set |
| 39 | +- **double getGamma()** returns gamma for speed set. |
| 40 | +- **double relativeTime(double time)** returns the relative time for speed set with **setSpeed()**. |
| 41 | +- **double relativeLength(double length)** returns the relative length for speed set. |
| 42 | +- **double relativeMass(double mass)** returns the relative mass for speed set. |
| 43 | +- **double EnergyMass(double mass)** returns the energy mass for for speed set. |
| 44 | + |
| 45 | + |
| 46 | +### Gravity effects |
| 47 | + |
| 48 | +- **double gravitationalTime(double time, double speed)** returns time dilation due to gravitational effects. |
| 49 | +- **double diameterEarth(uint8_t longitude = 45)** calculates the diameter of the Earth given it is not a nice circle but more an ellipse, flatter on the poles and thicker on the equator. |
| 50 | +Longitude is in (absolute) degrees. |
| 51 | +- **double getPlanetMass(uint8_t n)** returns planet mass in kg where 0 = Sun, 1 = Mercury etc |
| 52 | +- **double getPlanetRadius(uint8_t n)** returns planet radius in kg where 0 = Sun, 1 = Mercury etc |
| 53 | + |
| 54 | + |
| 55 | +## Operations |
| 56 | + |
| 57 | +See examples for typical usage. |
| 58 | + |
| 59 | + |
| 60 | +## Future |
| 61 | + |
| 62 | +- test test test test |
| 63 | +- add more functions |
| 64 | +- fix some overflow conditions. |
| 65 | + |
| 66 | +- add moons? |
| 67 | +- add caching version of mass / radius; |
0 commit comments