Browse Source

Add physics::time namespace, add function to calculate ERA from UT1

master
C. J. Howard 3 years ago
parent
commit
7c1bc2ff6b
4 changed files with 86 additions and 1 deletions
  1. +2
    -1
      src/ecs/systems/astronomy-system.cpp
  2. +1
    -0
      src/physics/physics.hpp
  3. +32
    -0
      src/physics/time/time.hpp
  4. +51
    -0
      src/physics/time/ut1.hpp

+ 2
- 1
src/ecs/systems/astronomy-system.cpp View File

@ -24,6 +24,7 @@
#include "renderer/passes/sky-pass.hpp" #include "renderer/passes/sky-pass.hpp"
#include "color/color.hpp" #include "color/color.hpp"
#include "physics/orbit/orbit.hpp" #include "physics/orbit/orbit.hpp"
#include "physics/time/ut1.hpp"
#include "geom/cartesian.hpp" #include "geom/cartesian.hpp"
#include <iostream> #include <iostream>
@ -122,7 +123,7 @@ void astronomy_system::update(double t, double dt)
const double earth_axial_tilt = math::radians(23.45); const double earth_axial_tilt = math::radians(23.45);
const double earth_axial_rotation = math::two_pi<double> * (0.7790572732640 + 1.00273781191135448 * universal_time);
const double earth_axial_rotation = physics::time::ut1::era(universal_time);
const double earth_radius_au = 4.2635e-5; const double earth_radius_au = 4.2635e-5;
const double observer_altitude = earth_radius_au; const double observer_altitude = earth_radius_au;

+ 1
- 0
src/physics/physics.hpp View File

@ -25,5 +25,6 @@ namespace physics {}
#include "frame.hpp" #include "frame.hpp"
#include "orbit/orbit.hpp" #include "orbit/orbit.hpp"
#include "time/time.hpp"
#endif // ANTKEEPER_PHYSICS_HPP #endif // ANTKEEPER_PHYSICS_HPP

+ 32
- 0
src/physics/time/time.hpp View File

@ -0,0 +1,32 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_PHYSICS_TIME_HPP
#define ANTKEEPER_PHYSICS_TIME_HPP
namespace physics {
/// Time-related functions.
namespace time {}
#include "ut1.hpp"
} // namespace physics
#endif // ANTKEEPER_PHYSICS_TIME_HPP

+ 51
- 0
src/physics/time/ut1.hpp View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_PHYSICS_TIME_UT1_HPP
#define ANTKEEPER_PHYSICS_TIME_UT1_HPP
#include "math/constants.hpp"
namespace physics {
namespace time {
/// Functions which operate on UT1 universal time.
namespace ut1 {
/**
* Calculates the Earth Rotation Angle (ERA) at a given UT1 date.
*
* @param t J2000 UT1 date.
* @return ERA at the given date, in radians.
*/
template <class T>
T era(T t);
template <class T>
T era(T t)
{
return math::two_pi<T> * (T(0.7790572732640) + T(1.00273781191135448) * t);
}
} // namespace ut1
} // namespace time
} // namespace physics
#endif // ANTKEEPER_PHYSICS_TIME_UT1_HPP

Loading…
Cancel
Save