This commit is contained in:
Timur A. Fatkhullin 2025-04-14 23:31:04 +03:00
parent a496c5cc54
commit a9d52aad0e
2 changed files with 29 additions and 8 deletions

View File

@ -3,11 +3,6 @@
#include "mcc_traits.h"
#include "utils.h"
namespace mcc
{
/* MCC-LIBRARY COORDINATES REPRESENTATION DEFINITIONS AND CLASS */
constexpr double operator""_rads(long double val) // angle in radians (no conversion)
{
return val;
@ -20,7 +15,7 @@ constexpr double operator""_degs(long double val) // angle in degrees
constexpr double operator""_dms(const char* s, size_t size) // as a string "DEGREES:MINUTES:SECONDS"
{
auto res = utils::parsAngleString(std::span{s, size});
auto res = mcc::utils::parsAngleString(std::span{s, size});
if (res.has_value()) {
return res.value() * std::numbers::pi / 180.0;
} else {
@ -28,9 +23,9 @@ constexpr double operator""_dms(const char* s, size_t size) // as a string "DEG
}
}
constexpr double operator""_hms(const char* s, size_t size) // as a string "HOURS:MINUTES:SECONDS"
constexpr double operator""_hms(const char* s, size_t len) // as a string "HOURS:MINUTES:SECONDS"
{
auto res = utils::parsAngleString(std::span{s, size}, true);
auto res = mcc::utils::parsAngleString(std::span{s, len}, true);
if (res.has_value()) {
return res.value() * std::numbers::pi / 180.0;
} else {
@ -39,6 +34,13 @@ constexpr double operator""_hms(const char* s, size_t size) // as a string "HOU
}
namespace mcc
{
/* MCC-LIBRARY COORDINATES REPRESENTATION DEFINITIONS AND CLASS */
// tags for MccCoordinate class construction
struct MccRadianTag {

View File

@ -1,6 +1,7 @@
#include <fstream>
#include <iostream>
#include "../mcc_coord.h"
#include "../mount_astrom.h"
@ -102,5 +103,23 @@ int main(int argc, char* argv[])
"comp time for {} coordinate transf = {}\n", N,
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - now));
std::cout << "\n\n\nMccCoordinate class test:\n";
mcc::MccCoordinate ra("12:00:00", mcc::mcc_hms);
std::cout << "sin(12h) = " << std::sin(ra) << "\n";
std::cout << "cos(12h) = " << std::cos(ra) << "\n";
ra = "18:00:00"_hms;
std::cout << "sin(18h) = " << std::sin(ra) << "\n";
std::cout << "cos(18h) = " << std::cos(ra) << "\n";
ra = mcc::MccCoordinate{45.0, mcc::mcc_degrees};
std::cout << "sin(45) = " << std::sin(ra) << "\n";
std::cout << "cos(45) = " << std::cos(ra) << "\n";
std::cout << ra.sexagesimal(false, 4) << "\n";
return ecode;
}