12 #include "RMF/config.h"
15 #include <boost/range/begin.hpp>
16 #include <boost/range/end.hpp>
17 #include <type_traits>
30 template <
unsigned int D>
32 :
public std::array<float, D>
34 typedef std::array<float, D> P;
36 template <
class R,
class Enabled =
void>
40 struct Convert<R, typename std::enable_if<std::is_convertible<
41 R, std::array<float, D> >::value>::type> {
42 static void convert(
const R& r, std::array<float, D>& d) { d = r; }
46 struct Convert<R, typename std::enable_if<!std::is_convertible<
47 R, std::array<float, D> >::value>::type> {
48 static void convert(
const R& r, std::array<float, D>& d) {
49 std::copy(boost::begin(r), boost::end(r), d.begin());
55 template <
class Range>
57 Convert<Range>::convert(r, *
this);
60 RMF_CXX11_DEFAULT_COPY_CONSTRUCTOR(
Vector);
62 Vector(
float x,
float y,
float z) {
63 static_assert(D == 3,
"Constructor only valid for Vector3");
68 Vector(
float x,
float y,
float z,
float q) {
69 static_assert(D == 4,
"Constructor only valid for Vector4");
75 RMF_SHOWABLE(
Vector, std::vector<float>(P::begin(), P::end()));
76 #if !defined(RMF_DOXYGEN)
77 float __getitem__(
unsigned int i)
const {
79 return P::operator[](i);
81 unsigned int __len__()
const {
return D; }
83 static unsigned int get_dimension() {
return D; }
87 template <
unsigned int D>
92 Vector(
const Vector<3U> &o);
93 Vector(
float x,
float y,
float z);
94 float __getitem__(
unsigned int i)
const;
95 unsigned int __len__()
const;
96 static unsigned int get_dimension();
101 Vector(
const Vector<4U> &o);
102 Vector(
float w,
float x,
float y,
float z);
103 float __getitem__(
unsigned int i)
const;
104 unsigned int __len__()
const;
105 static unsigned int get_dimension();
Represent a point in some dimension.
Declarations of the various exception types.
Various general useful macros for IMP.