Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overload ==operator in coordinate systems #134

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions include/boost/astronomy/coordinate/cartesian_representation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <boost/units/get_dimension.hpp>
#include <boost/units/systems/si/dimensionless.hpp>

#include <boost/test/tools/floating_point_comparison.hpp>

#include <boost/astronomy/detail/is_base_template_of.hpp>
#include <boost/astronomy/coordinate/base_representation.hpp>

Expand Down Expand Up @@ -205,6 +207,29 @@ struct cartesian_representation: base_representation<3, bg::cs::cartesian, Coord
>(result);
}

//!"==" operator to compare with other representations
template
<typename Representation>
bool operator ==(Representation const& other) const
{
auto tempRep1 = make_cartesian_representation(other);

return
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<XQuantity>(tempRep1.get_x()).value(),
this->get_x().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<YQuantity>(tempRep1.get_y()).value(),
this->get_y().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<ZQuantity>(tempRep1.get_z()).value(),
this->get_z().value());
}
}; //cartesian_representation


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <boost/units/systems/si/dimensionless.hpp>
#include <boost/units/systems/si/plane_angle.hpp>

#include <boost/test/tools/floating_point_comparison.hpp>

#include <boost/astronomy/detail/is_base_template_of.hpp>
#include <boost/astronomy/coordinate/base_differential.hpp>
#include <boost/astronomy/coordinate/cartesian_differential.hpp>
Expand Down Expand Up @@ -256,6 +258,28 @@ struct spherical_coslat_differential : public base_differential

return product;
}

//!"==" operator to compare with other differentials
template
<typename Differential>
bool operator ==(Differential const& other) const
{
auto tempRep1 = make_spherical_coslat_differential(other);

return
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<LatQuantity>(tempRep1.get_dlat()).value(),this->get_dlat().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<LonQuantity>(tempRep1.get_dlon_coslat()).value(),
this->get_dlon_coslat().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<DistQuantity>(tempRep1.get_ddist()).value(),this->get_ddist().value());
}
}; //spherical_coslat_differential

//!constructs object from provided components of differential
Expand Down
26 changes: 26 additions & 0 deletions include/boost/astronomy/coordinate/spherical_differential.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <boost/units/systems/si/dimensionless.hpp>
#include <boost/units/systems/si/plane_angle.hpp>

#include <boost/test/tools/floating_point_comparison.hpp>

#include <boost/astronomy/detail/is_base_template_of.hpp>
#include <boost/astronomy/coordinate/base_differential.hpp>
#include <boost/astronomy/coordinate/cartesian_differential.hpp>
Expand Down Expand Up @@ -249,6 +251,30 @@ struct spherical_differential : public base_differential

return product;
}

//!"==" operator to compare with other differentials
template
<typename Differential>
bool operator ==(Differential const& other) const
{
auto tempRep1 = make_spherical_differential(other);

return
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<LatQuantity>(tempRep1.get_dlat()).value(),
this->get_dlat().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<LonQuantity>(tempRep1.get_dlon()).value(),
this->get_dlon().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<DistQuantity>(tempRep1.get_ddist()).value(),
this->get_ddist().value());
}
}; //spherical_differential

//!constructs object from provided components of differential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <boost/units/systems/si/dimensionless.hpp>
#include <boost/units/systems/si/plane_angle.hpp>

#include <boost/test/tools/floating_point_comparison.hpp>

#include <boost/astronomy/detail/is_base_template_of.hpp>
#include <boost/astronomy/coordinate/base_differential.hpp>
#include <boost/astronomy/coordinate/cartesian_differential.hpp>
Expand Down Expand Up @@ -249,6 +251,30 @@ struct spherical_equatorial_differential : public base_differential

return product;
}

//!"==" operator to compare with other differentials
template
<typename Differential>
bool operator ==(Differential const& other) const
{
auto tempRep1 = make_spherical_equatorial_differential(other);

return
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<LatQuantity>(tempRep1.get_dlat()).value(),
this->get_dlat().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<LonQuantity>(tempRep1.get_dlon()).value(),
this->get_dlon().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<DistQuantity>(tempRep1.get_ddist()).value(),
this->get_ddist().value());
}
}; //spherical_equatorial_differential

//!constructs object from provided components of differential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <boost/units/get_dimension.hpp>
#include <boost/units/systems/si/dimensionless.hpp>

#include <boost/test/tools/floating_point_comparison.hpp>

#include <boost/astronomy/detail/is_base_template_of.hpp>
#include <boost/astronomy/coordinate/base_representation.hpp>
#include <boost/astronomy/coordinate/cartesian_representation.hpp>
Expand Down Expand Up @@ -227,6 +229,29 @@ struct spherical_equatorial_representation : public base_representation
return result;
}

//!"==" operator to compare with other representations
template
<typename Representation>
bool operator ==(Representation const& other) const
{
auto tempRep1 = make_spherical_equatorial_representation(other);

return
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<LatQuantity>(tempRep1.get_lat()).value(),
this->get_lat().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<LonQuantity>(tempRep1.get_lon()).value(),
this->get_lon().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<DistQuantity>(tempRep1.get_dist()).value(),
this->get_dist().value());
}
}; //spherical_equatorial_representation


Expand Down
26 changes: 26 additions & 0 deletions include/boost/astronomy/coordinate/spherical_representation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <boost/units/systems/si/plane_angle.hpp>
#include <boost/units/systems/si/dimensionless.hpp>

#include <boost/test/tools/floating_point_comparison.hpp>

#include <boost/astronomy/detail/is_base_template_of.hpp>
#include <boost/astronomy/coordinate/base_representation.hpp>
#include <boost/astronomy/coordinate/cartesian_representation.hpp>
Expand Down Expand Up @@ -204,6 +206,7 @@ struct spherical_representation : public base_representation
bg::set<2>(this->point, distance.value());
}

//!"+" operator to add any other representations
template<typename Addend>
spherical_representation
<
Expand Down Expand Up @@ -233,6 +236,29 @@ struct spherical_representation : public base_representation
return result;
}

//!"==" operator to compare with other representations
template
<typename Representation>
bool operator ==(Representation const& other) const
{
auto tempRep1 = make_spherical_representation(other);

return
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<LatQuantity>(tempRep1.get_lat()).value(),
this->get_lat().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<LonQuantity>(tempRep1.get_lon()).value(),
this->get_lon().value())
&&
boost::math::fpc::close_at_tolerance<CoordinateType>
(boost::math::fpc::percent_tolerance(1e-10),boost::math::fpc::FPC_STRONG)
(static_cast<DistQuantity>(tempRep1.get_dist()).value(),
this->get_dist().value());
}
}; //spherical_representation


Expand Down