point: add scalar division operation
This commit is contained in:
parent
c931c718fe
commit
09f5894d0c
15
point.cpp
15
point.cpp
@ -53,6 +53,21 @@ util::point<S,T>::operator* (T f) const {
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <size_t S, typename T>
|
||||
util::point<S,T>
|
||||
util::point<S,T>::operator/ (T f) const
|
||||
{
|
||||
point<S,T> out;
|
||||
|
||||
std::transform (std::begin (this->data),
|
||||
std::end (this->data),
|
||||
std::begin (out.data),
|
||||
[f] (auto i) { return i / f; });
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <size_t S, typename T>
|
||||
util::point<S,T>
|
||||
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with libgim. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Copyright 2011-14 Danny Robson <danny@nerdcruft.net>
|
||||
* Copyright 2011-2015 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#ifndef __UTIL_POINT_HPP
|
||||
@ -46,6 +46,8 @@ namespace util {
|
||||
// arithetic operators
|
||||
point<S,T>& operator*= (T);
|
||||
point<S,T> operator* (T) const;
|
||||
point<S,T> operator/ (T) const;
|
||||
|
||||
point<S,T> operator- (const point<S,T>&) const;
|
||||
|
||||
point<S,T> operator- (const vector<S,T>&) const;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with libgim. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Copyright 2014 Danny Robson <danny@nerdcruft.net>
|
||||
* Copyright 2014-2015 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#include "maths.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user