diff --git a/libs/kimath/include/math/vector2d.h b/libs/kimath/include/math/vector2d.h index 071258ace0..7ad7fc3d65 100644 --- a/libs/kimath/include/math/vector2d.h +++ b/libs/kimath/include/math/vector2d.h @@ -356,8 +356,8 @@ VECTOR2 VECTOR2::Resize( T aNewLength ) const extended_type y_sq = (extended_type) y * y; extended_type l_sq = x_sq + y_sq; extended_type newLength_sq = (extended_type) aNewLength * aNewLength; - extended_type newX = std::sqrt( rescale( newLength_sq, x_sq, l_sq ) ); - extended_type newY = std::sqrt( rescale( newLength_sq, y_sq, l_sq ) ); + double newX = std::sqrt( rescale( newLength_sq, x_sq, l_sq ) ); + double newY = std::sqrt( rescale( newLength_sq, y_sq, l_sq ) ); if( std::is_integral::value ) { diff --git a/qa/tests/libs/kimath/math/test_vector2.cpp b/qa/tests/libs/kimath/math/test_vector2.cpp index 5a03244f3f..402ac767b9 100644 --- a/qa/tests/libs/kimath/math/test_vector2.cpp +++ b/qa/tests/libs/kimath/math/test_vector2.cpp @@ -53,16 +53,18 @@ BOOST_AUTO_TEST_CASE( test_dot_product, *boost::unit_test::tolerance( 0.000001 ) BOOST_AUTO_TEST_CASE( test_resize, *boost::unit_test::tolerance( 0.000001 ) ) { - // a few vectors just to ensure the sign change happens as needed + // just some arbitrary vectors VECTOR2I v1( 4, 3 ); VECTOR2I v2( 5, -1 ); VECTOR2I v3( -2, 1 ); VECTOR2I v4( 1, 1 ); + VECTOR2I v5( -70, -70 ); - BOOST_CHECK( v1.Resize( 8 ) == VECTOR2I( 6, 4 ) ); - BOOST_CHECK( v2.Resize( 10 ) == VECTOR2I( 9, -2 ) ); - BOOST_CHECK( v3.Resize( 4 ) == VECTOR2I( -3, 1 ) ); + BOOST_CHECK( v1.Resize( 8 ) == VECTOR2I( 6, 5 ) ); + BOOST_CHECK( v2.Resize( 10 ) == VECTOR2I( 10, -2 ) ); + BOOST_CHECK( v3.Resize( 4 ) == VECTOR2I( -4, 2 ) ); BOOST_CHECK( v4.Resize( 1 ) == VECTOR2I( 1, 1 ) ); + BOOST_CHECK( v5.Resize( 100 ) == VECTOR2I( -71, -71 ) ); } BOOST_AUTO_TEST_SUITE_END()