/*
* This file is part of libgim.
*
* libgim is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* libgim is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see .
*
* Copyright 2011 Danny Robson
*/
#ifndef __UTIL_VECTOR_HPP
#define __UTIL_VECTOR_HPP
#include "json.hpp"
#include "detail/coord.hpp"
#include "annotations.hpp"
#include
#include
#include
namespace util {
template
struct vector : public detail::coord_data {
static_assert (S > 0, "vector dimensions must be strictly positive");
vector ();
template
vector (T ...t): detail::coord_data {std::forward (t)...} { ; }
util::vector operator* (double) const;
util::vector& operator*=(double);
util::vector operator/ (double) const;
util::vector& operator/=(double);
util::vector operator+ (double) const;
util::vector& operator+=(double);
util::vector operator- (double) const;
util::vector& operator-=(double);
util::vector operator* (const util::vector&) const;
util::vector& operator*=(const util::vector&);
util::vector operator+ (const util::vector&) const;
util::vector& operator+=(const util::vector&);
util::vector operator- (void) const;
util::vector operator- (const util::vector&) const;
util::vector& operator-=(const util::vector&);
util::vector& operator =(const util::vector &);
bool operator== (const util::vector &) const;
double magnitude (void) const;
double magnitude2 (void) const;
double dot (const util::vector&) const;
util::vector& normalise (void);
util::vector normalised (void) const mustuse;
bool is_zero (void) const;
void sanity (void) const;
};
vector<2> polar_to_cartesian (const vector<2>&);
vector<3> cross (const vector<3>&, const vector<3>&);
vector<3> spherical_to_cartesian (const util::vector <3>&);
vector<3> cartesian_to_spherical (const util::vector <3>&);
typedef vector<2> vector2;
typedef vector<3> vector3;
template util::vector operator* (double, const util::vector&);
template util::vector operator+ (double, const util::vector&);
template util::vector operator- (double, const util::vector&);
template std::ostream& operator<< (std::ostream&, const util::vector&);
template
const json::node& operator>> (const json::node&, util::vector&);
}
#endif