From 09f5894d0cf7517fced153cb7e140cb92d5791f5 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 15 Jan 2015 14:04:51 +1100 Subject: [PATCH] point: add scalar division operation --- point.cpp | 15 +++++++++++++++ point.hpp | 4 +++- point.ipp | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/point.cpp b/point.cpp index 2fa9baac..b22b3f48 100644 --- a/point.cpp +++ b/point.cpp @@ -53,6 +53,21 @@ util::point::operator* (T f) const { } +//----------------------------------------------------------------------------- +template +util::point +util::point::operator/ (T f) const +{ + point out; + + std::transform (std::begin (this->data), + std::end (this->data), + std::begin (out.data), + [f] (auto i) { return i / f; }); + + return out; +} + //----------------------------------------------------------------------------- template util::point diff --git a/point.hpp b/point.hpp index 44a74fd4..75402b90 100644 --- a/point.hpp +++ b/point.hpp @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with libgim. If not, see . * - * Copyright 2011-14 Danny Robson + * Copyright 2011-2015 Danny Robson */ #ifndef __UTIL_POINT_HPP @@ -46,6 +46,8 @@ namespace util { // arithetic operators point& operator*= (T); point operator* (T) const; + point operator/ (T) const; + point operator- (const point&) const; point operator- (const vector&) const; diff --git a/point.ipp b/point.ipp index 5f7030f3..12c0b912 100644 --- a/point.ipp +++ b/point.ipp @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with libgim. If not, see . * - * Copyright 2014 Danny Robson + * Copyright 2014-2015 Danny Robson */ #include "maths.hpp"