OGLplus  (0.59.0) a C++ wrapper for rendering APIs

axis.hpp
Go to the documentation of this file.
1 #ifndef EAGINE_VECT_AXIS_HPP
9 #define EAGINE_VECT_AXIS_HPP
10 
11 #include "data.hpp"
12 
13 namespace eagine::vect {
14 
15 template <typename T, int N, int I, bool V>
16 struct axis {
17  static auto apply(T v) noexcept -> data_t<T, N, V> {
18  data_t<T, N, V> r;
19  for(int i = 0; i < N; ++i) {
20  r[i] = (i == I) ? v : T(0);
21  }
22  return r;
23  }
24 };
25 
26 #if EAGINE_VECT_OPTS
27 
28 template <typename T, bool V>
29 struct axis<T, 1, 0, V> {
30  static constexpr auto apply(T v) noexcept {
31  return data_t<T, 1, V>{v};
32  }
33 };
34 
35 template <typename T, int I, bool V>
36 struct axis<T, 1, I, V> {
37  static constexpr auto apply(T) noexcept {
38  return data_t<T, 1, V>{0};
39  }
40 };
41 
42 template <typename T, bool V>
43 struct axis<T, 2, 0, V> {
44  static constexpr auto apply(T v) noexcept {
45  return data_t<T, 2, V>{v, T(0)};
46  }
47 };
48 
49 template <typename T, bool V>
50 struct axis<T, 2, 1, V> {
51  static constexpr auto apply(T v) noexcept {
52  return data_t<T, 2, V>{T(0), v};
53  }
54 };
55 
56 template <typename T, int I, bool V>
57 struct axis<T, 2, I, V> {
58  static constexpr auto apply(T) noexcept {
59  return data_t<T, 2, V>{T(0), T(0)};
60  }
61 };
62 
63 template <typename T, bool V>
64 struct axis<T, 3, 0, V> {
65  static constexpr auto apply(T v) noexcept {
66  return data_t<T, 3, V>{v, T(0), T(0)};
67  }
68 };
69 
70 template <typename T, bool V>
71 struct axis<T, 3, 1, V> {
72  static constexpr auto apply(T v) noexcept {
73  return data_t<T, 3, V>{T(0), v, T(0)};
74  }
75 };
76 
77 template <typename T, bool V>
78 struct axis<T, 3, 2, V> {
79  static constexpr auto apply(T v) noexcept {
80  return data_t<T, 3, V>{T(0), T(0), v};
81  }
82 };
83 
84 template <typename T, int I, bool V>
85 struct axis<T, 3, I, V> {
86  static constexpr auto apply(T) noexcept {
87  return data_t<T, 3, V>{T(0), T(0), T(0)};
88  }
89 };
90 
91 template <typename T, bool V>
92 struct axis<T, 4, 0, V> {
93  static constexpr auto apply(T v) noexcept {
94  return data_t<T, 4, V>{v, T(0), T(0), T(0)};
95  }
96 };
97 
98 template <typename T, bool V>
99 struct axis<T, 4, 1, V> {
100  static constexpr auto apply(T v) noexcept {
101  return data_t<T, 4, V>{T(0), v, T(0), T(0)};
102  }
103 };
104 
105 template <typename T, bool V>
106 struct axis<T, 4, 2, V> {
107  static constexpr auto apply(T v) noexcept {
108  return data_t<T, 4, V>{T(0), T(0), v, T(0)};
109  }
110 };
111 
112 template <typename T, bool V>
113 struct axis<T, 4, 3, V> {
114  static constexpr auto apply(T v) noexcept {
115  return data_t<T, 4, V>{T(0), T(0), T(0), v};
116  }
117 };
118 
119 template <typename T, int I, bool V>
120 struct axis<T, 4, I, V> {
121  static constexpr auto apply(T) noexcept {
122  return data_t<T, 4, V>{T(0), T(0), T(0), T(0)};
123  }
124 };
125 
126 #endif
127 
128 } // namespace eagine::vect
129 
130 #endif // EAGINE_VECT_AXIS_HPP

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).