33#include <NDEVR/Vector.h>
42 template<u
int01 t_dims,
class t_type,
class t_vector_type = Vector<t_dims, t_type>>
43 class Vertex :
public t_vector_type
49 constexpr explicit Vertex(
const t_type& scaler)
50 : t_vector_type(scaler)
52 constexpr Vertex(
const t_vector_type& vector)
53 : t_vector_type(vector)
55 constexpr Vertex(
const Vertex<t_dims, t_type, t_vector_type>& vector)
56 : t_vector_type(vector)
58 constexpr Vertex(
const t_type x,
const t_type y)
61 constexpr Vertex(t_type x, t_type y, t_type z)
62 : t_vector_type(x, y, z)
64 constexpr Vertex(
const t_type x,
const t_type y,
const t_type z,
const t_type w)
65 : t_vector_type(x, y, z, w)
67 constexpr explicit Vertex(
const t_type(&vector)[t_dims])
68 : t_vector_type(vector)
70 constexpr Vertex(
const Vector<
getMax(t_dims - 1, 0), t_type>& vector,
const t_type postfix)
71 : t_vector_type(vector, postfix)
73 constexpr Vertex(
const Vector<
getMax(t_dims - 2, 0), t_type>& vector,
const t_type postfix_a,
const t_type postfix_b)
74 : t_vector_type(vector, postfix_a, postfix_b)
76 constexpr Vertex(
const t_type prefix,
const Vector<t_dims - 1, t_type>& vector)
77 : t_vector_type(prefix, vector)
79 template<u
int01 t_new_dim,
class t_new_type,
class t_new_vector = Vector<t_new_dim, t_new_type>>
80 constexpr Vertex<t_new_dim, t_new_type, t_new_vector>
as()
const
82 return Vertex<t_new_dim, t_new_type, t_new_vector>(t_vector_type::template as<t_new_dim, t_new_type>());
84 template<
class t_new_type,
class t_new_vector = Vector<t_dims, t_new_type>>
85 constexpr Vertex<t_dims, t_new_type, t_new_vector>
as()
const
87 return Vertex<t_dims, t_new_type, t_new_vector>(t_vector_type::template as<t_dims, t_new_type>());
89 template<u
int01 t_new_dim,
class t_new_type,
class t_new_vector = Vector<t_new_dim, t_new_type>>
90 constexpr Vertex<t_new_dim, t_new_type, t_new_vector>
as(t_new_type extra_fill_value)
const
92 return Vertex<t_new_dim, t_new_type, t_new_vector>(t_vector_type::template as<t_new_dim, t_new_type>(extra_fill_value));
94 constexpr Vertex scale(
const t_vector_type& scale,
const Vertex<t_dims, t_type>& center)
const
96 return ((*
this - center) * scale) + center;
98 constexpr Vertex scale(
const t_type scale,
const Vertex<t_dims, t_type>& center)
const
100 return ((*
this - center) * scale) + center;
102 constexpr const Vertex& center()
const
106 constexpr Vertex<t_dims, t_type, t_vector_type>& operator=(
const t_type& scaler)
108 t_vector_type::operator=(scaler);
111 constexpr Vertex<t_dims, t_type, t_vector_type>& operator=(
const t_vector_type& vector)
113 t_vector_type::operator=(vector);
116 constexpr Vertex<t_dims, t_type, t_vector_type>& operator=(
const Vertex<t_dims, t_type, t_vector_type>& vector)
118 t_vector_type::operator=(vector);
122 template<u
int01 t_dims,
class t_type,
class t_base>
126 for (
uint01 dim = 0; dim < t_dims; dim++)
128 vec[dim] =
getMax(v1[dim], v2[dim]);
132 template<u
int01 t_dims,
class t_type,
class t_base>
136 for (
uint01 dim = 0; dim < t_dims; dim++)
138 vec[dim] =
getMin(v1[dim], v2[dim]);
142 template<u
int01 t_dims,
class t_type,
class t_vector_type>
145 constexpr const static Vertex<t_dims, t_type, t_vector_type> Invalid{ Constant<t_type>::Invalid };
146 constexpr const static Vertex<t_dims, t_type, t_vector_type> Min{ Constant<t_type>::Min };
147 constexpr const static Vertex<t_dims, t_type, t_vector_type> Max{ Constant<t_type>::Max };
149 template<u
int01 t_dims,
class t_type,
class t_vector_type>
152 for (
uint01 dim = 0; dim < t_dims; ++dim)
159 template<u
int01 t_dims,
class t_type,
class t_vector_type>
162 for (
uint01 dim = 0; dim < t_dims; ++dim)
169 template<u
int01 t_dims,
class t_type,
class t_vector_type = Vector<t_dims, t_type>>
170 class Ray :
public t_vector_type
176 constexpr explicit Ray(
const t_type& scaler)
177 : t_vector_type(scaler)
179 constexpr Ray(
const t_vector_type& vector)
180 : t_vector_type(vector)
182 constexpr Ray(
const Ray<t_dims, t_type, t_vector_type>& vector)
183 : t_vector_type(vector)
185 constexpr Ray(
const t_type x,
const t_type y)
186 : t_vector_type(x, y)
188 constexpr Ray(t_type x, t_type y, t_type z)
189 : t_vector_type(x, y, z)
191 constexpr Ray(
const t_type x,
const t_type y,
const t_type z,
const t_type w)
192 : t_vector_type(x, y, z, w)
194 constexpr explicit Ray(
const t_type(&vector)[t_dims])
195 : t_vector_type(vector)
197 constexpr Ray(
const Vector<
getMax(t_dims - 1, 0), t_type>& vector,
const t_type postfix)
198 : t_vector_type(vector, postfix)
200 constexpr Ray(
const Vector<
getMax(t_dims - 2, 0), t_type>& vector,
const t_type postfix_a,
const t_type postfix_b)
201 : t_vector_type(vector, postfix_a, postfix_b)
203 constexpr Ray(
const t_type prefix,
const Vector<t_dims - 1, t_type>& vector)
204 : t_vector_type(prefix, vector)
206 template<u
int01 t_new_dim,
class t_new_type,
class t_new_vector = Vector<t_new_dim, t_new_type>>
207 constexpr Ray<t_new_dim, t_new_type, t_new_vector>
as(t_new_type extra_fill_value = 0)
const
209 return Ray<t_new_dim, t_new_type, t_new_vector>(t_vector_type::template as<t_new_dim, t_new_type>(extra_fill_value));
211 template<
class t_new_type,
class t_new_vector = Vector<t_dims, t_new_type>>
212 constexpr Ray<t_dims, t_new_type, t_new_vector>
as()
const
214 return Ray<t_dims, t_new_type, t_new_vector>(t_vector_type::template as<t_new_type>());
216 constexpr Ray scale(
const t_vector_type& scale)
const
218 return (*
this * scale);
220 constexpr Ray scale(
const t_type scale)
const
222 return (*
this * scale);
224 constexpr Ray<t_dims, t_type, t_vector_type>& operator=(
const t_type& scaler)
226 t_vector_type::operator=(scaler);
229 constexpr Ray<t_dims, t_type, t_vector_type>& operator=(
const t_vector_type& vector)
231 t_vector_type::operator=(vector);
234 constexpr Ray<t_dims, t_type, t_vector_type>& operator=(
const Ray<t_dims, t_type, t_vector_type>& vector)
236 t_vector_type::operator=(vector);
240 template<u
int01 t_dims,
class t_type,
class t_base>
241 constexpr Ray<t_dims, t_type, t_base>
getMax(
const Ray<t_dims, t_type, t_base>& v1,
const Ray<t_dims, t_type, t_base >& v2)
243 Ray<t_dims, t_type, t_base> vec;
244 for (
uint01 dim = 0; dim < t_dims; dim++)
250 template<u
int01 t_dims,
class t_type,
class t_base>
251 constexpr Ray<t_dims, t_type, t_base>
getMin(
const Ray<t_dims, t_type, t_base>& v1,
const Ray<t_dims, t_type, t_base>& v2)
253 Ray<t_dims, t_type, t_base> vec;
254 for (
uint01 dim = 0; dim < t_dims; dim++)
260 template<u
int01 t_dims,
class t_type,
class t_vector_type>
261 struct Constant<Ray<t_dims, t_type, t_vector_type>>
263 constexpr const static Ray<t_dims, t_type, t_vector_type> Invalid{ Constant<t_vector_type>::Invalid };
264 constexpr const static Ray<t_dims, t_type, t_vector_type> Min{ 0 };
265 constexpr const static Ray<t_dims, t_type, t_vector_type> Max{ Constant<t_vector_type>::Max };
267 template<u
int01 t_dims,
class t_type,
class t_vector_type>
268 static constexpr bool IsInvalid(
const Ray<t_dims, t_type, t_vector_type>& value)
270 for (
uint01 dim = 0; dim < t_dims; ++dim)
277 template<u
int01 t_dims,
class t_type,
class t_vector_type>
278 static constexpr bool IsValid(
const Ray<t_dims, t_type, t_vector_type>& value)
280 for (
uint01 dim = 0; dim < t_dims; ++dim)
291 struct hash<Vertex<3, fltp08>>
293 std::size_t operator()(
const Vertex<3, fltp08>& s)
const noexcept
295 std::size_t h = 0, g = 0;
296 const uint01* bytes =
reinterpret_cast<const uint01*
>(&s[0]);
297 for (
size_t i = 0; i < 3 *
sizeof(
fltp08); i++)
299 h = (h << 4) + bytes[i];
309 struct hash<Vertex<3, fltp04>>
311 std::size_t operator()(
const Vertex<3, fltp04>& s)
const noexcept
313 std::size_t h = 0, g = 0;
314 const uint01* bytes =
reinterpret_cast<const uint01*
>(&s[0]);
315 for (
size_t i = 0; i < 3 *
sizeof(
fltp04); i++)
317 h = (h << 4) + bytes[i];
constexpr decltype(auto) as() const
Returns the vector as a new time of vector.
A point in N-dimensional space, used primarily for spatial location information.
The primary namespace for the NDEVR SDK.
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
constexpr t_type getMax(const t_type &left, const t_type &right)
Finds the max of the given arguments using the > operator The only requirement is that t_type have > ...
static constexpr bool IsValid(const Angle< t_type > &value)
Checks whether the given Angle holds a valid value.
constexpr Angle< t_angle_type > abs(const Angle< t_angle_type > &value)
Changes an input with a negative sign, to a positive sign.
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
static constexpr bool IsInvalid(const Angle< t_type > &value)
Checks whether the given Angle holds an invalid value.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...