63 explicit RA(
double inDegrees) :
67 if (inDegrees < 0 || inDegrees >= 360)
73 const double decMinutes = (degrees_ -
static_cast<double>(hours_) * 15.) * 4.;
75 seconds_ =
static_cast<double>((decMinutes -
static_cast<double>(minutes_)) * 60.);
90 degrees_ =
static_cast<double>(hours_) * 15. +
static_cast<double>(minutes_) / 4. + seconds_ / 240.;
99 [[nodiscard]]
double radians() const noexcept
149 [[nodiscard]] std::string
str()
const
186 return !(*
this == inRhs);
195 friend std::ostream&
operator<<(std::ostream& inStream,
const RA& inRa)
197 inStream << inRa.
str();
205 double seconds_{ 0. };
206 double degrees_{ 0. };
207 double radians_{ 0. };
233 explicit Dec(
double inDegrees) :
237 if (inDegrees < -90 || inDegrees > 90)
243 const double absDegrees =
std::abs(degrees_);
246 const double decMinutes = (absDegrees -
static_cast<double>(degreesWhole_)) * 60.;
248 seconds_ = (decMinutes -
static_cast<double>(minutes_)) * 60.;
261 degreesWhole_(inDegrees),
265 degrees_ =
static_cast<double>(degreesWhole_) +
static_cast<double>(minutes_) / 60. + seconds_ / 3600.;
308 return degreesWhole_;
336 [[nodiscard]] std::string
str()
const
339 std::string out =
"Dec dms: " + strSign +
utils::num2str(degreesWhole_) +
" degrees, " +
374 return !(*
this == inRhs);
387 inStream << inDec.
str();
394 uint8 degreesWhole_{ 0 };
396 double seconds_{ 0. };
397 double degrees_{ 0. };
398 double radians_{ 0. };
439 uint8 inDecDegreesWhole,
441 double inDecSeconds) :
442 ra_(inRaHours, inRaMinutes, inRaSeconds),
443 dec_(inSign, inDecDegreesWhole, inDecMinutes, inDecSeconds)
482 x_(inCartesianVector.
x),
483 y_(inCartesianVector.
y),
484 z_(inCartesianVector.
z)
495 x_(inCartesianVector.
x),
496 y_(inCartesianVector.
y),
497 z_(inCartesianVector.
z)
509 if (inCartesianVector.
size() != 3)
514 x_ = inCartesianVector[0];
515 y_ = inCartesianVector[1];
516 z_ = inCartesianVector[2];
526 [[nodiscard]]
const Dec&
dec() const noexcept
536 [[nodiscard]]
const RA&
ra() const noexcept
546 [[nodiscard]]
double x() const noexcept
556 [[nodiscard]]
double y() const noexcept
566 [[nodiscard]]
double z() const noexcept
616 return std::acos(
dot(
xyz(), inOtherCelestial.
xyz()).item());
629 if (inVector.
size() != 3)
642 [[nodiscard]] std::string
str()
const
644 std::string returnStr;
645 returnStr = ra_.
str();
646 returnStr += dec_.
str();
647 returnStr +=
"Cartesian = " +
xyz().
str();
668 return ra_ == inRhs.ra_ && dec_ == inRhs.dec_;
680 return !(*
this == inRhs);
693 inStream << inCoord.
str();
708 void cartesianToPolar()
710 double degreesRa =
rad2deg(std::atan2(y_, x_));
718 const double degreesDec =
rad2deg(std::asin(z_ / r));
719 dec_ = Dec(degreesDec);
725 void polarToCartesian() noexcept
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
size_type size() const noexcept
Definition: NdArrayCore.hpp:4524
self_type flatten() const
Definition: NdArrayCore.hpp:2847
std::string str() const
Definition: NdArrayCore.hpp:4582
Holds a 3D vector.
Definition: Vec3.hpp:51
Cartensian coordinates.
Definition: Cartesian.hpp:45
Holds a full celestial Celestial object.
Definition: Celestial.hpp:404
Celestial(uint8 inRaHours, uint8 inRaMinutes, double inRaSeconds, Dec::Sign inSign, uint8 inDecDegreesWhole, uint8 inDecMinutes, double inDecSeconds)
Definition: Celestial.hpp:435
Celestial(double inX, double inY, double inZ)
Definition: Celestial.hpp:468
friend std::ostream & operator<<(std::ostream &inStream, const Celestial &inCoord)
Definition: Celestial.hpp:691
double y() const noexcept
Definition: Celestial.hpp:556
const RA & ra() const noexcept
Definition: Celestial.hpp:536
Celestial(const Cartesian &inCartesianVector)
Definition: Celestial.hpp:481
double z() const noexcept
Definition: Celestial.hpp:566
bool operator==(const Celestial &inRhs) const noexcept
Definition: Celestial.hpp:666
Celestial(const RA &inRA, const Dec &inDec) noexcept
Definition: Celestial.hpp:454
Celestial(const NdArray< double > &inCartesianVector)
Definition: Celestial.hpp:507
double degreeSeperation(const NdArray< double > &inVector) const
Definition: Celestial.hpp:602
double radianSeperation(const Celestial &inOtherCelestial) const
Definition: Celestial.hpp:614
Celestial(double inRaDegrees, double inDecDegrees)
Definition: Celestial.hpp:417
std::string str() const
Definition: Celestial.hpp:642
NdArray< double > xyz() const
Definition: Celestial.hpp:576
const Dec & dec() const noexcept
Definition: Celestial.hpp:526
bool operator!=(const Celestial &inRhs) const noexcept
Definition: Celestial.hpp:678
double degreeSeperation(const Celestial &inOtherCelestial) const
Definition: Celestial.hpp:589
Celestial(const Vec3 &inCartesianVector)
Definition: Celestial.hpp:494
double x() const noexcept
Definition: Celestial.hpp:546
double radianSeperation(const NdArray< double > &inVector) const
Definition: Celestial.hpp:627
void print() const
Definition: Celestial.hpp:654
Holds a Declination object.
Definition: Celestial.hpp:213
double degrees() const noexcept
Definition: Celestial.hpp:286
Sign sign() const noexcept
Definition: Celestial.hpp:276
friend std::ostream & operator<<(std::ostream &inStream, const Dec &inDec)
Definition: Celestial.hpp:385
double radians() const noexcept
Definition: Celestial.hpp:296
uint8 minutes() const noexcept
Definition: Celestial.hpp:316
void print() const
Definition: Celestial.hpp:348
Dec(Sign inSign, uint8 inDegrees, uint8 inMinutes, double inSeconds) noexcept
Definition: Celestial.hpp:259
uint8 degreesWhole() const noexcept
Definition: Celestial.hpp:306
std::string str() const
Definition: Celestial.hpp:336
bool operator==(const Dec &inRhs) const noexcept
Definition: Celestial.hpp:360
double seconds() const noexcept
Definition: Celestial.hpp:326
Dec(double inDegrees)
Definition: Celestial.hpp:233
bool operator!=(const Dec &inRhs) const noexcept
Definition: Celestial.hpp:372
Sign
Struct Enum for positive or negative Dec angle.
Definition: Celestial.hpp:218
Holds a right ascension object.
Definition: Celestial.hpp:51
uint8 minutes() const noexcept
Definition: Celestial.hpp:129
double radians() const noexcept
Definition: Celestial.hpp:99
double seconds() const noexcept
Definition: Celestial.hpp:139
void print() const
Definition: Celestial.hpp:160
double degrees() const noexcept
Definition: Celestial.hpp:109
friend std::ostream & operator<<(std::ostream &inStream, const RA &inRa)
Definition: Celestial.hpp:195
uint8 hours() const noexcept
Definition: Celestial.hpp:119
RA(double inDegrees)
Definition: Celestial.hpp:63
bool operator==(const RA &inRhs) const noexcept
Definition: Celestial.hpp:172
std::string str() const
Definition: Celestial.hpp:149
RA(uint8 inHours, uint8 inMinutes, double inSeconds) noexcept
Definition: Celestial.hpp:85
bool operator!=(const RA &inRhs) const noexcept
Definition: Celestial.hpp:184
std::string num2str(dtype inNumber)
Definition: num2str.hpp:44
bool essentiallyEqual(dtype inValue1, dtype inValue2) noexcept
Definition: essentiallyEqual.hpp:49
constexpr dtype sqr(dtype inValue) noexcept
Definition: sqr.hpp:42
constexpr auto deg2rad(dtype inValue) noexcept
Definition: deg2rad.hpp:47
auto sin(dtype inValue) noexcept
Definition: sin.hpp:49
NdArray< dtype > dot(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2)
Definition: dot.hpp:47
auto abs(dtype inValue) noexcept
Definition: abs.hpp:49
auto cos(dtype inValue) noexcept
Definition: cos.hpp:49
dtype floor(dtype inValue) noexcept
Definition: floor.hpp:48
constexpr auto rad2deg(dtype inValue) noexcept
Definition: rad2deg.hpp:48
auto sqrt(dtype inValue) noexcept
Definition: sqrt.hpp:48
std::uint8_t uint8
Definition: Types.hpp:42