point: add from function
This commit is contained in:
parent
a2055b30bf
commit
8a0eee50e3
17
point.cpp
17
point.cpp
@ -28,10 +28,11 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <size_t S, typename T>
|
||||
util::vector<S,T>
|
||||
util::point<S,T>::to (const point<S,T> &rhs) const {
|
||||
util::point<S,T>::to (const point<S,T> &rhs) const
|
||||
{
|
||||
util::vector<S,T> out;
|
||||
|
||||
for (size_t i = 0; i < S; ++i)
|
||||
@ -42,6 +43,18 @@ util::point<S,T>::to (const point<S,T> &rhs) const {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <size_t S, typename T>
|
||||
util::vector<S,T>
|
||||
util::point<S,T>::from (const point<S,T> &rhs) const
|
||||
{
|
||||
util::vector<S,T> out;
|
||||
for (size_t i = 0; i < S; ++i)
|
||||
out.data[i] = this->data[i] - rhs.data[i];
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <size_t S, typename T>
|
||||
void
|
||||
util::point<S,T>::sanity (void) const {
|
||||
CHECK (std::all_of (begin (this->data),
|
||||
|
@ -42,6 +42,7 @@ namespace util {
|
||||
template <typename U> typename std::common_type<T,U>::type manhattan (const point<S,U> &) const;
|
||||
|
||||
vector<S,T> to (const point&) const;
|
||||
vector<S,T> from (const point&) const;
|
||||
|
||||
template <size_t D> point<D,T> redim (void) const;
|
||||
template <size_t D> point<D,T> redim (const util::point<D,T> &fill) const;
|
||||
|
Loading…
Reference in New Issue
Block a user