Exemplo n.º 1
0
void test_azimuth(double lon1, double lat1,
                  double lon2, double lat2,
                  double expected_azimuth_deg)
{
    // Set radius type, but for integer coordinates we want to have floating point radius type
    typedef typename bg::promote_floating_point
        <
            typename bg::coordinate_type<PS>::type
        >::type rtype;

    typedef bg::srs::spheroid<rtype> stype;
    typedef bg::detail::andoyer_inverse<rtype, false, true> andoyer_inverse_type;

    rtype a_formula = andoyer_inverse_type::apply(to_rad(lon1), to_rad(lat1), to_rad(lon2), to_rad(lat2), stype()).azimuth;

    rtype azimuth_deg = to_deg(a_formula);

    if (bg::math::equals(azimuth_deg, -180.0))
        azimuth_deg = 180.0;
    if (bg::math::equals(expected_azimuth_deg, -180.0))
        expected_azimuth_deg = 180.0;

    if (bg::math::equals(expected_azimuth_deg, 0.0))
    {
        BOOST_CHECK(bg::math::equals(azimuth_deg, expected_azimuth_deg));
    }
    else
    {
        BOOST_CHECK_CLOSE(azimuth_deg, expected_azimuth_deg, 0.001);
    }
}
Exemplo n.º 2
0
Arquivo: vec3.hpp Projeto: Bartzi/CG2
 template <typename T> T angle_between(const vec3<T>& a, const vec3<T>& b) {
     return to_deg(atan2(cross_prod(a,b).length(), dot_prod(a,b)));
 }
Exemplo n.º 3
0
//! Converts radians to degrees.
double vposition::degf( const double rad )
{
  return to_deg(rad);
}
Exemplo n.º 4
0
//! Extracts decimal part minutes from float radian.
double vposition::minf( const double rad )
{
  float const deg = to_deg(rad);
  return ( deg - floor(deg) ) * 60.0;
}
Exemplo n.º 5
0
using namespace y::math;

y_test_func("Quaternion from_euler pitch") {
	auto q = Quaternion<>::from_euler(to_rad(90), 0, 0);

	y_test_assert(q({1.0f, 0.0f, 0.0f}).z() < -0.99f);
	y_test_assert(q({0.0f, 0.0f, 1.0f}).x() > 0.99f);
	y_test_assert(to_deg(q.pitch()) == 90.0f);
}

y_test_func("Quaternion from_euler yaw") {
	auto q = Quaternion<>::from_euler(0, to_rad(90), 0);

	y_test_assert(q({1.0f, 0.0f, 0.0f}).y() > 0.99f);
	y_test_assert(q({0.0f, 0.0f, 1.0f}).z() > 0.99f);
	y_test_assert(to_deg(q.yaw()) == 90.0f);
}

y_test_func("Quaternion from_euler roll") {
	auto q = Quaternion<>::from_euler(0, 0, to_rad(90));

	y_test_assert(q({1.0f, 0.0f, 0.0f}).x() > 0.99f);
	y_test_assert(q({0.0f, 0.0f, 1.0f}).y() < -0.99f);
	y_test_assert(to_deg(q.roll()) == 90.0f);
}

y_test_func("Quaternion default values") {
	Quaternion<> quat;

	y_test_assert(quat({1.0f, 0.0f, 0.0f}).x() > 0.99f);
	y_test_assert(quat({0.0f, 1.0f, 0.0f}).y() > 0.99f);