diff --git a/test/coordinate/CMakeLists.txt b/test/coordinate/CMakeLists.txt index 0306678e..895c208c 100644 --- a/test/coordinate/CMakeLists.txt +++ b/test/coordinate/CMakeLists.txt @@ -10,6 +10,7 @@ foreach(_name spherical_differential spherical_equatorial_representation spherical_equatorial_differential + spherical_coslat_differential utility) set(_target test_coordinate_${_name}) diff --git a/test/coordinate/Jamfile b/test/coordinate/Jamfile index c8a6f6ea..1c8f0123 100644 --- a/test/coordinate/Jamfile +++ b/test/coordinate/Jamfile @@ -12,4 +12,4 @@ run ecliptic_coord.cpp ; run equatorial_ra_coord.cpp ; run equatorial_ha_coord.cpp ; run utility.cpp ; - +run spherical_coslat_differential.cpp ; diff --git a/test/coordinate/spherical_coslat_differential.cpp b/test/coordinate/spherical_coslat_differential.cpp new file mode 100644 index 00000000..b1d0b95d --- /dev/null +++ b/test/coordinate/spherical_coslat_differential.cpp @@ -0,0 +1,243 @@ +/*============================================================================= +Copyright 2021 Divyam Singal + +Distributed under the Boost Software License, Version 1.0. (See accompanying +file License.txt or copy at https://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#define BOOST_TEST_MODULE spherical_coslat_differential_test + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace boost::astronomy::coordinate; +using namespace boost::units::si; +using namespace boost::geometry; +using namespace boost::units; +namespace bud = boost::units::degree; + +BOOST_AUTO_TEST_SUITE(spherical_coslat_differential_constructors) + +BOOST_AUTO_TEST_CASE(spherical_coslat_differential_default_constructor) +{ + //using set functions + spherical_coslat_differential, quantity, + quantity> motion1; + motion1.set_dlat_dlon_coslat_ddist(45.0 * bud::degrees, 18.0 * bud::degrees, 3.5 * meters / seconds); + BOOST_CHECK_CLOSE(motion1.get_dlat().value(), 45.0, 0.001); + BOOST_CHECK_CLOSE(motion1.get_dlon_coslat().value(), 18.0, 0.001); + BOOST_CHECK_CLOSE(motion1.get_ddist().value(), 3.5, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); +} + +BOOST_AUTO_TEST_CASE(spherical_coslat_differential_quantities_constructor) +{ + //checking construction from value + auto motion1 = make_spherical_coslat_differential + (15.0 * bud::degrees, 39.0 * bud::degrees, 3.0 * si::centi * meter / seconds); + BOOST_CHECK_CLOSE(motion1.get_dlat().value(), 15.0, 0.001); + BOOST_CHECK_CLOSE(motion1.get_dlon_coslat().value(), 39.0, 0.001); + BOOST_CHECK_CLOSE(motion1.get_ddist().value(), 3.0, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same::type>>::value)); + + spherical_coslat_differential, quantity, + quantity> motion2(1.5 * bud::degrees, 9.0 * bud::degrees, 3.0 * meter / seconds); + BOOST_CHECK_CLOSE(motion2.get_dlat().value(), 1.5, 0.001); + BOOST_CHECK_CLOSE(motion2.get_dlon_coslat().value(), 9.0, 0.001); + BOOST_CHECK_CLOSE(motion2.get_ddist().value(), 3, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); +} + +BOOST_AUTO_TEST_CASE(spherical_coslat_differential_copy_constructor) +{ + //checking construction from value + auto motion1 = make_spherical_coslat_differential + (15.0 * bud::degrees, 30.0 * bud::degrees, 3.0 * si::centi * meter / seconds); + BOOST_CHECK_CLOSE(motion1.get_dlat().value(), 15.0, 0.001); + BOOST_CHECK_CLOSE(motion1.get_dlon_coslat().value(), 30.0, 0.001); + BOOST_CHECK_CLOSE(motion1.get_ddist().value(), 3, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same::type>>::value)); + + //copy constructor + auto motion2 = make_spherical_coslat_differential(motion1); + BOOST_CHECK_CLOSE(motion1.get_dlat().value(), motion2.get_dlat().value(), 0.001); + BOOST_CHECK_CLOSE(motion1.get_dlon_coslat().value(), motion2.get_dlon_coslat().value(), 0.001); + BOOST_CHECK_CLOSE(motion1.get_ddist().value(), motion2.get_ddist().value(), 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same::type>>::value)); +} + +BOOST_AUTO_TEST_CASE(spherical_coslat_differential_copy_constructor_with_different_units) +{ + //checking construction from value + auto motion1 = make_spherical_coslat_differential + (15.0 * bud::degrees, 10.0 * bud::degrees, 3.0 * si::centi * meter / seconds); + BOOST_CHECK_CLOSE(motion1.get_dlat().value(), 15.0, 0.001); + BOOST_CHECK_CLOSE(motion1.get_dlon_coslat().value(), 10.0, 0.001); + BOOST_CHECK_CLOSE(motion1.get_ddist().value(), 3, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same::type>>::value)); + + //Conversion from one unit type to other + auto motion2 = make_spherical_coslat_differential + , quantity, quantity>(motion1); + BOOST_CHECK_CLOSE(motion2.get_dlat().value(), 15.0, 0.001); + BOOST_CHECK_CLOSE(motion2.get_dlon_coslat().value(), 10.0, 0.001); + BOOST_CHECK_CLOSE(motion2.get_ddist().value(), 0.03, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); +} + +BOOST_AUTO_TEST_CASE(spherical_coslat_differential_geometry_point_constructor) +{ + //constructing from boost::geometry::model::motion + model::point model_point(30, 60, 10); + auto motion1 = make_spherical_coslat_differential + , quantity, quantity>(model_point); + BOOST_CHECK_CLOSE(motion1.get_dlat().value(), 63.434948822922, 0.001); + BOOST_CHECK_CLOSE(motion1.get_dlon_coslat().value(), 81.521286852914, 0.001); + BOOST_CHECK_CLOSE(motion1.get_ddist().value(), 67.823299831253, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + + spherical_coslat_differential, quantity, + quantity> motion2(model_point); + BOOST_CHECK_CLOSE(motion2.get_dlat().value(), 63.434948822922, 0.001); + BOOST_CHECK_CLOSE(motion2.get_dlon_coslat().value(), 81.521286852914, 0.001); + BOOST_CHECK_CLOSE(motion2.get_ddist().value(), 67.823299831253, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); +} + +BOOST_AUTO_TEST_CASE(spherical_coslat_differential_conversion_from_cartesian_differential) +{ + //constructing from spherical differential + auto cartesian_motion = make_cartesian_differential(20.0 * meters / seconds, + 60.0 * meters / seconds, 1.0 * meter / seconds); + auto motion1 = make_spherical_coslat_differential(cartesian_motion); + BOOST_CHECK_CLOSE(motion1.get_dlat().value(), 1.2490457723983, 0.001); + BOOST_CHECK_CLOSE(motion1.get_dlon_coslat().value(), 0.49172982989398, 0.001); + BOOST_CHECK_CLOSE(motion1.get_ddist().value(), 63.253458403474, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); +} + +BOOST_AUTO_TEST_CASE(spherical_coslat_differential_conversion_from_spherical_differential) +{ + //constructing from spherical_equitorial differential + auto spherical_equatorial_motion = make_spherical_differential + (0.523599 * si::radian, 60.0 * bud::degrees, 1.0 * meter / seconds); + auto motion2 = make_spherical_coslat_differential(spherical_equatorial_motion); + BOOST_CHECK_CLOSE(motion2.get_dlat().value(), 0.523599, 0.001); + BOOST_CHECK_CLOSE(motion2.get_dlon_coslat().value(), 0.90689956, 0.001); + BOOST_CHECK_CLOSE(motion2.get_ddist().value(), 1.0, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); +} + +BOOST_AUTO_TEST_CASE(spherical_coslat_differential_conversion_from_spherical_equatorial_differential) +{ + //constructing from spherical_equitorial differential + auto spherical_equatorial_motion = make_spherical_equatorial_differential + (0.523599 * si::radian, 60.0 * bud::degrees, 1.0 * meter / seconds); + auto motion2 = make_spherical_coslat_differential(spherical_equatorial_motion); + BOOST_CHECK_CLOSE(motion2.get_dlat().value(), 0.523599, 0.001); + BOOST_CHECK_CLOSE(motion2.get_dlon_coslat().value(), 0.45344978231, 0.001); + BOOST_CHECK_CLOSE(motion2.get_ddist().value(), 1.0, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); +} + +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(spherical_coslat_differential_operators) + +BOOST_AUTO_TEST_CASE(spherical_coslat_differential_addition_operator) +{ + auto motion1 = make_spherical_coslat_differential(15.0 * bud::degrees, 30.0 * bud::degrees, 10.0 * meters / seconds); + auto motion2 = make_spherical_coslat_differential(30.0 * bud::degrees, 45.0 * bud::degrees, 20.0 * meters / seconds); + + auto sum = make_spherical_coslat_differential(motion1 + motion2); + + BOOST_CHECK_CLOSE(sum.get_dlat().value(), 26.402183706, 0.001); + BOOST_CHECK_CLOSE(sum.get_dlon_coslat().value(), 39.859953684, 0.001); + BOOST_CHECK_CLOSE(sum.get_ddist().value(), 29.421195378, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); +} + +BOOST_AUTO_TEST_CASE(spherical_coslat_differential_multiplication_operator) +{ + auto motion1 = make_spherical_coslat_differential(15.0 * bud::degrees, 30.0 * bud::degrees, 10.0 * meters / seconds); + + spherical_coslat_differential, quantity, + quantity> product = make_spherical_differential(motion1 * quantity(5.0 * seconds)); + + BOOST_CHECK_CLOSE(product.get_dlat().value(), 15.0, 0.001); + BOOST_CHECK_CLOSE(product.get_dlon_coslat().value(), 30.0, 0.001); + BOOST_CHECK_CLOSE(product.get_ddist().value(), 50.0, 0.001); + + //checking whether quantity stored is as expected or not + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); + BOOST_TEST((std::is_same>::value)); +} + +BOOST_AUTO_TEST_SUITE_END() +