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
8namespace nngn {
9
10template<typename T>
11struct 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
23template<typename T>
24struct vec_type<T, 2> : std::type_identity<vec2_base<T>> {};
25
31
32static_assert(offsetof(ivec2, y) == sizeof(ivec2::type));
33static_assert(offsetof(uvec2, y) == sizeof(uvec2::type));
34static_assert(offsetof( vec2, y) == sizeof( vec2::type));
35static_assert(offsetof(dvec2, y) == sizeof(dvec2::type));
36
37}
38
39#endif
#define T(f0, f1, f2)
Definition audio.cpp:7
v[1]
Definition math.lua:22
Definition vec2.h:11
constexpr vec2_base()=default
constexpr vec2_base(T p_x, T p_y)
Definition vec2.h:15
T x
Definition vec2.h:12
constexpr vec2_base(T v)
Definition vec2.h:14
T y
Definition vec2.h:12
Definition vec.h:16
Definition vec.h:22
std::int32_t type
Definition vec.h:23
#define S(v0, v1)
Definition vec2.h:16