From d0e18bdb7924c71cdca8dd983711171d87ef28be Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Mon, 17 Jan 2022 23:12:32 -0500 Subject: glplanet, an OpenGL-based planetary renderer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit glplanet draws Earth like it currently appears from space, putting nighttime areas in shadow and daytime areas in light. It’s modeled after Xplanet (http://xplanet.sourceforge.net/), but whereas Xplanet is entirely a CPU-resident program, glplanet draws using OpenGL. It’s thus much less resource-intensive, particularly when using high-resolution textures. --- src/astro_test.cc | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/astro_test.cc (limited to 'src/astro_test.cc') diff --git a/src/astro_test.cc b/src/astro_test.cc new file mode 100644 index 0000000..2fc1cb8 --- /dev/null +++ b/src/astro_test.cc @@ -0,0 +1,64 @@ +// Copyright 2022 Benjamin Barenblat +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +#include "src/astro.h" + +#include +#include + +#include + +#include "third_party/date/include/date/tz.h" + +namespace glplanet { +namespace { + +using ::testing::DoubleNear; +using ::testing::Pair; + +TEST(SunEquatorialPositionTest, MeeusExercise25A) { + // October 13, 1992, at 00:00:00 TDT (T = -0.072'183'436) + constexpr auto t = + std::chrono::time_point() + + std::chrono::days(34 * 365 + 8 /* leap days */) + + std::chrono::days(31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 11) + + std::chrono::hours(23) + std::chrono::minutes(59) + + std::chrono::milliseconds(27'816); + EXPECT_THAT(SunEquatorialPosition(t), Pair(DoubleNear(-2.82078673, 1e-8), + DoubleNear(-0.1358751, 1e-8))); +} + +TEST(ApparentSiderealTimeAtGreenwichTest, MeeusExercise12A) { + // April 10, 1987, at 00:00:00 UT (T = -0.127'296'372'348) + constexpr auto t = + std::chrono::time_point() + + std::chrono::days(29 * 365 + 7 /* leap days */) + + std::chrono::days(31 + 28 + 31 + 8) + std::chrono::hours(23) + + std::chrono::minutes(59) + std::chrono::milliseconds(27'816); + EXPECT_THAT(ApparentSiderealTimeAtGreenwich(t), DoubleNear(-2.832805, 1e-6)); +} + +TEST(HighNoonLocationTest, MarchEquinox) { + // March 20, 2022 15:29:52.331 UT + constexpr auto t = + std::chrono::time_point() + + std::chrono::days(64 * 365 + 16 /* leap days */) + + std::chrono::days(31 + 28 + 19) + std::chrono::hours(15) + + std::chrono::minutes(29) + std::chrono::milliseconds(24'515); + EXPECT_THAT(HighNoonLocation(t), + Pair(DoubleNear(-0.883655431852, 1e-10), DoubleNear(0.0, 1e-10))); +} + +} // namespace +} // namespace glplanet -- cgit v1.2.3