From e7a76081e0f4c473df593f51af7882036a14a919 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 16 Apr 2018 15:54:08 +1000 Subject: [PATCH] point: don't directly iterate over data --- point.cpp | 26 +------------------------- point.hpp | 6 +++--- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/point.cpp b/point.cpp index bbda9bc6..d4730efd 100644 --- a/point.cpp +++ b/point.cpp @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Copyright 2011-2016 Danny Robson + * Copyright 2011-2018 Danny Robson */ #include "point.hpp" @@ -23,30 +23,6 @@ using util::point; -/////////////////////////////////////////////////////////////////////////////// -template -util::vector -util::point::to (point rhs) const -{ - util::vector out; - for (size_t i = 0; i < S; ++i) - out.data[i] = rhs.data[i] - this->data[i]; - return out; -} - - -//----------------------------------------------------------------------------- -template -util::vector -util::point::from (point rhs) const -{ - util::vector out; - for (size_t i = 0; i < S; ++i) - out.data[i] = this->data[i] - rhs.data[i]; - return out; -} - - /////////////////////////////////////////////////////////////////////////////// namespace util::debug { template diff --git a/point.hpp b/point.hpp index d6568cdb..4967cb6f 100644 --- a/point.hpp +++ b/point.hpp @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Copyright 2011-2016 Danny Robson + * Copyright 2011-2018 Danny Robson */ #ifndef CRUFT_UTIL_POINT_HPP @@ -34,8 +34,8 @@ namespace util { { using coord::base>::base; - vector to (point) const; - vector from (point) const; + vector to (point dst) const { return dst - *this; } + vector from (point src) const { return *this - src; } /// expand point to use homogenous coordinates of a higher dimension. /// ie, fill with (0,..,0,1)