summaryrefslogtreecommitdiffstats
path: root/engine/include/symbasic/svector.hpp
blob: c53ae0fd4f2734e8c07ece7dd217706ec4ccb2a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef __STATIC_VECTOR_H__
#define __STATIC_VECTOR_H__

#include <array>
#include "vector.h"

template<class T, std::size_t N> 
class SVector : public Vector<T>
{

public:

    /* Constructors */

    SVector(const T &value = T());
    SVector(const std::initializer_list<T> &init);
    SVector(const SVector<T, N>&);

    SVector& operator=(const SVector<T, N>&);

	virtual const size_t size() const override;

	virtual T& operator[](size_t i) override;
	virtual const T& operator[](size_t i) const override;

    /* Plus / minus */
    SVector<T, N>& operator+=(const Vector<T>&);
    SVector<T, N>& operator-=(const Vector<T>&);

    /* Scalar multiplication / division */
    SVector<T, N>& operator*=(double k);
    SVector<T, N>& operator/=(double k);

    /* Reverse operator */
    SVector<T, N>& operator~();

    /* Unit vector */
    SVector<T, N>& unit();

private:

    std::array<T, N> components;
};

template<class T, std::size_t N>
const SVector<T, N> operator+(SVector<T, N> , const Vector<T>& );

template<class T, std::size_t N>
const SVector<T, N> operator-(SVector<T, N> , const Vector<T>& );

template<class T, std::size_t N>
const SVector<T, N> operator*(SVector<T, N> , double);

template<class T, std::size_t N>
const SVector<T, N> operator/(SVector<T, N> , double);

template<class T, std::size_t N>
const SVector<T, N> operator*(double, SVector<T, N>);

template<class T, std::size_t N>
const SVector<T, N> operator/(double, SVector<T, N>);

template<class T, std::size_t N>
const SVector<T, N> operator-(SVector<T, N>);

/*
 * Prototipe for cross product
 */
inline const SVector<double, 3> operator^(const SVector<double, 3>& v, const SVector<double, 3>& w);
inline double operator^(const SVector<double, 2>& v, const SVector<double, 2>& w);
inline double operator^(const SVector<double, 1>& v, const SVector<double, 1>& w);

/*
 * Include definitions file
 */
#include "svector.tpp"

#endif // __SVECTOR_H__