0.1.2 relativity

This commit is contained in:
rob tillaart 2021-12-27 20:50:10 +01:00
parent 040a73748d
commit 871eb7d0a9
11 changed files with 50 additions and 32 deletions

View File

@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
- leonardo
- due
- zero
- leonardo
- m4
- esp32
- esp8266
- mega2560

View File

@ -4,10 +4,14 @@ name: Arduino CI
on: [push, pull_request]
jobs:
arduino_ci:
runTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Arduino-CI/action@master
# Arduino-CI/action@v0.1.1
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021-2021 Rob Tillaart
Copyright (c) 2021-2022 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,7 @@
[![Arduino CI](https://github.com/RobTillaart/relativity/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/relativity/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/relativity/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/relativity/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/relativity/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/relativity/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/relativity.svg?maxAge=3600)](https://github.com/RobTillaart/relativity/releases)
@ -11,18 +13,19 @@ Arduino library with relativity functions.
## Description
This experimental library implements a number of functions that give indication of the time dilation etc due to relativistic speed.
This experimental library implements a number of functions that give an
indication of the time dilation etcetera due to relativistic speed.
Goal: Educational purposes or when one puts a cubesat into space :)
Goal: Educational purposes or when one puts a cube-sat into space :)
## Interface
- **relativity()** constructor
- **double getC()** returns speed of light
- **double getG()** returns gravitational constant
- **double factor(double speed)** returns sqrt(1-v2/c2)
- **double gamma(double speed)** returns 1/sqrt(1-v2/c2)
- **relativity()** constructor.
- **double getC()** returns speed of light.
- **double getG()** returns gravitational constant.
- **double factor(double speed)** returns sqrt(1-v2/c2).
- **double gamma(double speed)** returns 1/sqrt(1-v2/c2).
- **double relativeTime(double time, double speed)** returns the relative time for given time and speed.
- **double relativeLength(double length, double speed)** returns the relative length for given length and speed.
- **double relativeMass(double mass, double speed)** returns the relative mass for given mass and speed.
@ -31,11 +34,12 @@ Goal: Educational purposes or when one puts a cubesat into space :)
### Caching variants
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.
These functions are the same however the math to calculate a given factor and gamma is done only once and cached.
So these functions will perform a bit better, especially if floating point is slow.
- **void setSpeed(double speed = 0)** set the speed once and calculate the factor and gamma to minimize math for next functions. Think caching.
- **void setSpeed(double speed = 0)** set the speed and calculate the factor and gamma to minimize math for next functions.
- **double getSpeed()** returns speed set.
- **double getFactor()** returns factor for speed set
- **double getFactor()** returns factor for speed set.
- **double getGamma()** returns gamma for speed set.
- **double relativeTime(double time)** returns the relative time for speed set with **setSpeed()**.
- **double relativeLength(double length)** returns the relative length for speed set.
@ -46,12 +50,13 @@ These functions are the same however the math to calculate a given factor and ga
### Gravity effects
- **double gravitationalTime(double time, double speed)** returns time dilation due to gravitational effects.
- **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.
Longitude is in (absolute) degrees.
- **double diameterEarth(double 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.
Longitude is in degrees -90 .. 90.
- **double getPlanetMass(uint8_t n)** returns planet mass in **kg**
where param n: 0 = Sun, 1 = Mercury etc
where parameter n: 0 = Sun, 1 = Mercury etc.
- **double getPlanetRadius(uint8_t n)** returns planet radius in **km**
where param n: 0 = Sun, 1 = Mercury etc
where parameter n: 0 = Sun, 1 = Mercury etc.
## Operations
@ -64,6 +69,5 @@ See examples for typical usage.
- test test test test
- add more functions
- fix some overflow conditions.
- add moons?
- add caching version of mass / radius;

View File

@ -1,7 +1,6 @@
//
// FILE: gamma_table.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: test formulas
// DATE: 2021-05-29
// URL: https://github.com/RobTillaart/relativity
@ -14,6 +13,7 @@ uint32_t start, stop;
relativity R;
void setup()
{
Serial.begin(115200);
@ -46,4 +46,6 @@ void loop()
{
}
// -- END OF FILE --

View File

@ -1,7 +1,6 @@
//
// FILE: gravity_demo.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: test formulas
// DATE: 2021-05-29
// URL: https://github.com/RobTillaart/relativity
@ -35,4 +34,6 @@ void loop()
{
}
// -- END OF FILE --

View File

@ -1,7 +1,6 @@
//
// FILE: relativity_demo.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: test formulas
// DATE: 2021-05-29
// URL: https://github.com/RobTillaart/relativity
@ -48,4 +47,6 @@ void loop()
{
}
// -- END OF FILE --

View File

@ -15,8 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/relativity.git"
},
"version": "0.1.1",
"version": "0.1.2",
"license": "MIT",
"frameworks": "*",
"platforms": "*"
"platforms": "*",
"headers": "relativity.h"
}

View File

@ -1,5 +1,5 @@
name=relativity
version=0.1.1
version=0.1.2
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=library with relativity functions.

View File

@ -2,19 +2,20 @@
//
// FILE: relativity.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// VERSION: 0.1.2
// PURPOSE: Collection relativity formulas
// URL: https://github.com/RobTillaart/relativity
//
// HISTORY:
// 0.1.0 2021-05-29 initial version
// 0.1.1 2021-06-02 fix in tests
// 0.1.2 2021-12-27 update library.json, readme, license, minor edits
#include "Arduino.h"
#define RELATIVITY_LIB_VERSION (F("0.1.1"))
#define RELATIVITY_LIB_VERSION (F("0.1.2"))
class relativity
@ -122,7 +123,7 @@ public:
}
// returns radius in km.
double radiusEarth(uint8_t longitude = 45) // 0..90
double radiusEarth(double longitude = 45) // 0..90
{
// https://www.youtube.com/watch?v=hYMvJum9_Do @ 8:00
// radius polar: 6357 km
@ -130,7 +131,7 @@ public:
// difference: 21 km
double radians = longitude * (PI / 180.0);
// approx of the graph in youtube with a cosine
// approx of the graph in YouTube with a cosine
return 6367.5 + 10.5 * cos(radians * 2);
}
@ -194,3 +195,4 @@ private:
// -- END OF FILE --

View File

@ -37,6 +37,7 @@
unittest_setup()
{
fprintf(stderr, "RELATIVITY_LIB_VERSION: %s\n", (char*) RELATIVITY_LIB_VERSION);
}
@ -47,8 +48,6 @@ unittest_teardown()
unittest(test_constructor)
{
fprintf(stderr, "VERSION: %s\n", RELATIVITY_LIB_VERSION);
relativity R;
// test constants