Two method aliases in RBA::Vector/DVector to provide Point compatibility

This commit is contained in:
Matthias Koefferlein 2017-10-29 19:11:50 +01:00
parent c1377cc276
commit 52e893ae17
2 changed files with 10 additions and 2 deletions

View File

@ -230,11 +230,13 @@ struct vector_defs
"\n"
"@return 1 if the scalar product is positive, 0 if it is zero and -1 if it is negative.\n"
) +
method ("length", (double (C::*) () const) &C::double_length,
method ("length|abs", (double (C::*) () const) &C::double_length,
"@brief Returns the length of the vector\n"
"'abs' is an alias provided for compatibility with the former point type."
) +
method ("sq_length", (double (C::*) () const) &C::sq_double_length,
method ("sq_length|sq_abs", (double (C::*) () const) &C::sq_double_length,
"@brief The square length of the vector\n"
"'sq_abs' is an alias provided for compatibility with the former point type."
) +
constructor ("from_s", &from_string,
"@brief Creates an object from a string\n"

View File

@ -50,6 +50,9 @@ class DBVector_TestClass < TestBase
assert_equal( a.y.to_s, "-17.0" )
assert_equal( (a.length - Math::sqrt(17 * 17 + 1 * 1)).abs < 1e-12, true )
assert_equal( (a.sq_length - (17 * 17 + 1 * 1)).abs < 1e-12, true )
assert_equal( (a.abs - Math::sqrt(17 * 17 + 1 * 1)).abs < 1e-12, true )
assert_equal( (a.sq_abs - (17 * 17 + 1 * 1)).abs < 1e-12, true )
b.x = a.x
b.y = a.y
@ -101,6 +104,9 @@ class DBVector_TestClass < TestBase
assert_equal( a.y.to_s, "-17" )
assert_equal( (a.length - Math::sqrt(17 * 17 + 1 * 1)).abs < 1e-12, true )
assert_equal( (a.sq_length - (17 * 17 + 1 * 1)).abs < 1e-12, true )
assert_equal( (a.abs - Math::sqrt(17 * 17 + 1 * 1)).abs < 1e-12, true )
assert_equal( (a.sq_abs - (17 * 17 + 1 * 1)).abs < 1e-12, true )
b.x = a.x
b.y = a.y