💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.6 KiB

  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_CELESTIAL_COORDINATES_HPP
  20. #define ANTKEEPER_CELESTIAL_COORDINATES_HPP
  21. #include "utility/fundamental-types.hpp"
  22. namespace ast
  23. {
  24. /**
  25. * Converts rectangular coordinates to spherical coordinates.
  26. *
  27. * @param rectangular Rectangular coordinates.
  28. * @return Equivalent spherical coordinates, in the ISO order of radial distance, polar angle (radians), and azimuthal angle (radians).
  29. */
  30. double3 rectangular_to_spherical(const double3& rectangular);
  31. /**
  32. * Convert spherical coordinates to rectangular coordinates.
  33. *
  34. * @param spherical Spherical coordinates, in the ISO order of radial distance, polar angle (radians), and azimuthal angle (radians).
  35. * @return Equivalent rectangular coordinates.
  36. */
  37. double3 spherical_to_rectangular(const double3& spherical);
  38. /**
  39. * Produces a matrix which transforms rectangular coordinates from ecliptic space to equatorial space.
  40. *
  41. * @param ecl Obliquity of the ecliptic, in radians.
  42. * @return Transformation matrix.
  43. */
  44. double3x3 ecliptic_to_equatorial(double ecl);
  45. /**
  46. * Produces a matrix which transforms coordinates from ecliptic space to horizontal space.
  47. *
  48. * @param ecl Obliquity of the ecliptic, in radians.
  49. * @param lat Observer's latitude, in radians.
  50. * @param lst Local sidereal time, in radians.
  51. * @return Transformation matrix.
  52. */
  53. double3x3 ecliptic_to_horizontal(double ecl, double lat, double lst);
  54. /**
  55. * Produces a matrix which transforms rectangular coordinates from equatorial space to ecliptic space.
  56. *
  57. * @param ecl Obliquity of the ecliptic, in radians.
  58. * @return Transformation matrix.
  59. */
  60. double3x3 equatorial_to_ecliptic(double ecl);
  61. /**
  62. * Produces a matrix which transforms rectangular coordinates from equatorial space to horizontal space.
  63. *
  64. * @param lat Observer's latitude, in radians.
  65. * @param lst Local sidereal time, in radians.
  66. * @return Transformation matrix.
  67. */
  68. double3x3 equatorial_to_horizontal(double lat, double lst);
  69. /**
  70. * Produces a matrix which transforms rectangular coordinates from horizontal space to equatorial space.
  71. *
  72. * @param lat Observer's latitude, in radians.
  73. * @param lst Local sidereal time, in radians.
  74. * @return Transformation matrix.
  75. */
  76. double3x3 horizontal_to_equatorial(double lat, double lst);
  77. /**
  78. * Produces a matrix which transforms rectangular coordinates from horizontal space to ecliptic space.
  79. *
  80. * @param ecl Obliquity of the ecliptic, in radians.
  81. * @param lat Observer's latitude, in radians.
  82. * @param lst Local sidereal time, in radians.
  83. * @return Transformation matrix.
  84. */
  85. double3x3 horizontal_to_ecliptic(double ecl, double lat, double lst);
  86. /// Matrix which transforms coordinates from horizontal space to a right-handed coordinate system.
  87. constexpr double3x3 horizontal_to_right_handed =
  88. {
  89. 0.0, 0.0, 1.0,
  90. 1.0, 0.0, 0.0,
  91. 0.0, -1.0, 0.0
  92. };
  93. } // namespace ast
  94. #endif // ANTKEEPER_CELESTIAL_COORDINATES_HPP