From 52e893ae170a62cbe367274a96a1c998823d5a59 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 29 Oct 2017 19:11:50 +0100 Subject: [PATCH] Two method aliases in RBA::Vector/DVector to provide Point compatibility --- src/db/db/gsiDeclDbVector.cc | 6 ++++-- testdata/ruby/dbVectorTest.rb | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/db/db/gsiDeclDbVector.cc b/src/db/db/gsiDeclDbVector.cc index 0d679f1e0..26b4cae1b 100644 --- a/src/db/db/gsiDeclDbVector.cc +++ b/src/db/db/gsiDeclDbVector.cc @@ -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" diff --git a/testdata/ruby/dbVectorTest.rb b/testdata/ruby/dbVectorTest.rb index e9b30509c..7a38b68ed 100644 --- a/testdata/ruby/dbVectorTest.rb +++ b/testdata/ruby/dbVectorTest.rb @@ -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