diff --git a/include/boost/astronomy/coordinate/cartesian_representation.hpp b/include/boost/astronomy/coordinate/cartesian_representation.hpp index 871f905c..ebef29e1 100644 --- a/include/boost/astronomy/coordinate/cartesian_representation.hpp +++ b/include/boost/astronomy/coordinate/cartesian_representation.hpp @@ -14,6 +14,8 @@ #include #include +#include + #include #include @@ -205,6 +207,29 @@ struct cartesian_representation: base_representation<3, bg::cs::cartesian, Coord >(result); } + //!"==" operator to compare with other representations + template + + bool operator ==(Representation const& other) const + { + auto tempRep1 = make_cartesian_representation(other); + + return + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_x()).value(), + this->get_x().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_y()).value(), + this->get_y().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_z()).value(), + this->get_z().value()); + } }; //cartesian_representation diff --git a/include/boost/astronomy/coordinate/spherical_coslat_differential.hpp b/include/boost/astronomy/coordinate/spherical_coslat_differential.hpp index f762aa3f..ab6091f0 100644 --- a/include/boost/astronomy/coordinate/spherical_coslat_differential.hpp +++ b/include/boost/astronomy/coordinate/spherical_coslat_differential.hpp @@ -16,6 +16,8 @@ #include #include +#include + #include #include #include @@ -256,6 +258,28 @@ struct spherical_coslat_differential : public base_differential return product; } + + //!"==" operator to compare with other differentials + template + + bool operator ==(Differential const& other) const + { + auto tempRep1 = make_spherical_coslat_differential(other); + + return + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_dlat()).value(),this->get_dlat().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_dlon_coslat()).value(), + this->get_dlon_coslat().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_ddist()).value(),this->get_ddist().value()); + } }; //spherical_coslat_differential //!constructs object from provided components of differential diff --git a/include/boost/astronomy/coordinate/spherical_differential.hpp b/include/boost/astronomy/coordinate/spherical_differential.hpp index 73ea1404..b301a220 100644 --- a/include/boost/astronomy/coordinate/spherical_differential.hpp +++ b/include/boost/astronomy/coordinate/spherical_differential.hpp @@ -15,6 +15,8 @@ #include #include +#include + #include #include #include @@ -249,6 +251,30 @@ struct spherical_differential : public base_differential return product; } + + //!"==" operator to compare with other differentials + template + + bool operator ==(Differential const& other) const + { + auto tempRep1 = make_spherical_differential(other); + + return + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_dlat()).value(), + this->get_dlat().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_dlon()).value(), + this->get_dlon().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_ddist()).value(), + this->get_ddist().value()); + } }; //spherical_differential //!constructs object from provided components of differential diff --git a/include/boost/astronomy/coordinate/spherical_equatorial_differential.hpp b/include/boost/astronomy/coordinate/spherical_equatorial_differential.hpp index 783cd8a4..f43fde20 100644 --- a/include/boost/astronomy/coordinate/spherical_equatorial_differential.hpp +++ b/include/boost/astronomy/coordinate/spherical_equatorial_differential.hpp @@ -15,6 +15,8 @@ #include #include +#include + #include #include #include @@ -249,6 +251,30 @@ struct spherical_equatorial_differential : public base_differential return product; } + + //!"==" operator to compare with other differentials + template + + bool operator ==(Differential const& other) const + { + auto tempRep1 = make_spherical_equatorial_differential(other); + + return + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_dlat()).value(), + this->get_dlat().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_dlon()).value(), + this->get_dlon().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_ddist()).value(), + this->get_ddist().value()); + } }; //spherical_equatorial_differential //!constructs object from provided components of differential diff --git a/include/boost/astronomy/coordinate/spherical_equatorial_representation.hpp b/include/boost/astronomy/coordinate/spherical_equatorial_representation.hpp index 79602115..60747c5f 100644 --- a/include/boost/astronomy/coordinate/spherical_equatorial_representation.hpp +++ b/include/boost/astronomy/coordinate/spherical_equatorial_representation.hpp @@ -15,6 +15,8 @@ #include #include +#include + #include #include #include @@ -227,6 +229,29 @@ struct spherical_equatorial_representation : public base_representation return result; } + //!"==" operator to compare with other representations + template + + bool operator ==(Representation const& other) const + { + auto tempRep1 = make_spherical_equatorial_representation(other); + + return + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_lat()).value(), + this->get_lat().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_lon()).value(), + this->get_lon().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_dist()).value(), + this->get_dist().value()); + } }; //spherical_equatorial_representation diff --git a/include/boost/astronomy/coordinate/spherical_representation.hpp b/include/boost/astronomy/coordinate/spherical_representation.hpp index 4165aeb5..7d960ff3 100644 --- a/include/boost/astronomy/coordinate/spherical_representation.hpp +++ b/include/boost/astronomy/coordinate/spherical_representation.hpp @@ -14,6 +14,8 @@ #include #include +#include + #include #include #include @@ -204,6 +206,7 @@ struct spherical_representation : public base_representation bg::set<2>(this->point, distance.value()); } + //!"+" operator to add any other representations template spherical_representation < @@ -233,6 +236,29 @@ struct spherical_representation : public base_representation return result; } + //!"==" operator to compare with other representations + template + + bool operator ==(Representation const& other) const + { + auto tempRep1 = make_spherical_representation(other); + + return + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_lat()).value(), + this->get_lat().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_lon()).value(), + this->get_lon().value()) + && + boost::math::fpc::close_at_tolerance + (boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG) + (static_cast(tempRep1.get_dist()).value(), + this->get_dist().value()); + } }; //spherical_representation