Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wolgemoth committed May 1, 2024
1 parent 33cc682 commit f3a86ae
Show file tree
Hide file tree
Showing 2 changed files with 234 additions and 2 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# vsop87-wrapper
A wrapper class providing a clean interface for working with Greg Miller's VSOP87-Multilang
# VSOP87 Wrapper

### About

This project implements a wrapper providing with a clean interface for those for working with the C++ version of Greg Miller's VSOP87-Multilang and the glm maths library.

If you find a bug or have a feature-request, please raise an issue.

### Dependencies

#### [VSOP87-Multilang](http://www.celestialprogramming.com/vsop87-multilang/index.html)
#### [OpenGL Mathematics 0.9.9.8 (GLM)](https://www.opengl.org/sdk/libs/GLM/)

### Instructions

The implementation is header-only and written in templated C++17. You should need not need to make any adjustments to your project settings or compiler flags.

Simply include the header and its dependencies in your project and you are ready to start!
216 changes: 216 additions & 0 deletions VSOP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
#ifndef LOUIERIKSSON_VSOP_HPP
#define LOUIERIKSSON_VSOP_HPP

#include <glm/detail/qualifier.hpp>
#include <vsop87a_full.h>

namespace LouiEriksson {

/**
* @mainpage Version 1.0.0
*
* @brief Class representing the VSOP astronomical coordinate system.
*
* The VSOP class provides functions for obtaining position information of celestial bodies.
*
* @tparam T The underlying type of the vector components.
* @tparam Q The precision of the vector components.
*/
template <typename T, glm::precision Q>
struct VSOP final {

private:

/**
* @brief Changes the handedness of a 3D vector.
*
* This function takes a 3D vector and returns a new vector with changed handedness.
*
* @tparam T The underlying type of the vector components.
* @tparam P The precision of the vector components.
* @param[in] _vec The input vector.
* @return The new vector with changed handedness.
*/
template<typename T, glm::precision Q>
static constexpr glm::vec<3, T, Q> ChangeHandedness(const glm::vec<3, T, Q>& _vec) {
return { -_vec.x, _vec.z, _vec.y };
}

public:

struct Position final {

private:

glm::vec<3, T, Q> m_Spherical;
glm::vec<3, T, Q> m_Cartesian;
glm::qua< T, Q> m_Rotation;

public:

constexpr const glm::vec<3, T, Q>& Spherical() const noexcept { return m_Spherical; }
constexpr const glm::vec<3, T, Q>& Cartesian() const noexcept { return m_Cartesian; }
constexpr const glm::qua< T, Q>& Rotation() const noexcept { return m_Rotation; }

constexpr Position(const glm::vec<3, T, Q>& _spherical, const glm::vec<3, T, Q>& _cartesian, const glm::vec<3, T, Q>& _rotation) noexcept :
m_Spherical(_spherical),
m_Cartesian(_cartesian),
m_Rotation (_rotation ) {}

constexpr Position() noexcept :
m_Spherical{},
m_Cartesian{},
m_Rotation {} {}
};

struct V87 final {

struct A final {

static Position GetSol() {
return {
{},
{ 0.0, 0.0, 0.0 },
{}
};
}

static Position GetMercury(const double& _time) {

double tmp[3];

vsop87a_full::getMercury(_time, tmp);

return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}

static Position GetVenus(const double& _time) {

double tmp[3];

vsop87a_full::getVenus(_time, tmp);

return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}

static Position GetEarth(const double& _time) {

double tmp[3];

vsop87a_full::getEarth(_time, tmp);

return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}

static Position GetEMB(const double& _time) {

double tmp[3];

vsop87a_full::getEmb(_time, tmp);

return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}

static Position GetMoon(const Position& _earth, const Position& _emb) {

auto e1 = ChangeHandedness<double, Q>(_earth.Cartesian());
auto e2 = ChangeHandedness<double, Q>( _emb.Cartesian());

double tmp[3];

vsop87a_full::getMoon(&e1[0], &e2[0], tmp);

return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{},
};
}

static Position GetMars(const double& _time) {

double tmp[3];

vsop87a_full::getMars(_time, tmp);

return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}

static Position GetJupiter(const double& _time) {

double tmp[3];

vsop87a_full::getJupiter(_time, tmp);

return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}

static Position GetSaturn(const double& _time) {

double tmp[3];

vsop87a_full::getSaturn(_time, tmp);

return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}

static Position GetUranus(const double& _time) {

double tmp[3];

vsop87a_full::getUranus(_time, tmp);

return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}

static Position GetNeptune(const double& _time) {

double tmp[3];

vsop87a_full::getNeptune(_time, tmp);

return {
{},
{ ChangeHandedness<T, Q>({ tmp[0], tmp[1], tmp[2] }) },
{}
};
}
};
};
};

} // LouiEriksson

#endif //LOUIERIKSSON_VSOP_HPP

0 comments on commit f3a86ae

Please sign in to comment.