nngn
Loading...
Searching...
No Matches
vec2.h
Go to the documentation of this file.
1
#ifndef NNGN_MATH_VEC2_H
2
#define NNGN_MATH_VEC2_H
3
4
#include <cstdint>
5
6
#include "
vec.h
"
7
8
namespace
nngn
{
9
10
template
<
typename
T>
11
struct
vec2_base
:
public
vec
<vec2_base, T, 2> {
12
T
x
,
y
;
13
constexpr
vec2_base
() =
default
;
14
explicit
constexpr
vec2_base
(
T
v
) :
x
(
v
),
y
(
v
) {}
15
constexpr
vec2_base
(
T
p_x,
T
p_y) :
x
(p_x),
y
(p_y) {}
16
#define S(v0, v1) \
17
constexpr vec2_base<T> v0 ## v1() const { return {this->v0, this->v1}; }
18
S
(
x
,
x
)
S
(
x
,
y
)
19
S
(
y
,
x
)
S
(
y
,
y
)
20
#undef S
21
};
22
23
template
<
typename
T>
24
struct
vec_type
<
T
, 2> : std::type_identity<vec2_base<T>> {};
25
26
using
ivec2
=
vec2_base<std::int32_t>
;
27
using
uvec2
=
vec2_base<std::uint32_t>
;
28
using
zvec2
=
vec2_base<std::size_t>
;
29
using
vec2
=
vec2_base<float>
;
30
using
dvec2
=
vec2_base<double>
;
31
32
static_assert
(offsetof(
ivec2
, y) ==
sizeof
(
ivec2::type
));
33
static_assert
(offsetof(
uvec2
, y) ==
sizeof
(
uvec2::type
));
34
static_assert
(offsetof(
vec2
, y) ==
sizeof
(
vec2::type
));
35
static_assert
(offsetof(
dvec2
, y) ==
sizeof
(
dvec2::type
));
36
37
}
38
39
#endif
T
#define T(f0, f1, f2)
nngn
Definition
audio.cpp:7
v
v[1]
Definition
math.lua:22
nngn::vec2_base
Definition
vec2.h:11
nngn::vec2_base::vec2_base
constexpr vec2_base()=default
nngn::vec2_base::vec2_base
constexpr vec2_base(T p_x, T p_y)
Definition
vec2.h:15
nngn::vec2_base::x
T x
Definition
vec2.h:12
nngn::vec2_base::vec2_base
constexpr vec2_base(T v)
Definition
vec2.h:14
nngn::vec2_base::y
T y
Definition
vec2.h:12
nngn::vec_type
Definition
vec.h:16
nngn::vec
Definition
vec.h:22
nngn::vec< vec2_base, std::int32_t, 2 >::type
std::int32_t type
Definition
vec.h:23
S
#define S(v0, v1)
Definition
vec2.h:16
vec.h
src
math
vec2.h
Generated by
1.11.0