SGCT
master (487fac4)
Simple Graphics Cluster Toolkit
Toggle main menu visibility
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1
/*****************************************************************************************
2
* SGCT *
3
* Simple Graphics Cluster Toolkit *
4
* *
5
* Copyright (c) 2012-2026 *
6
* For conditions of distribution and use, see copyright notice in LICENSE.md *
7
****************************************************************************************/
8
9
#ifndef __SGCT__MATH_H__
10
#define __SGCT__MATH_H__
11
12
#include <sgct/sgctexports.h>
13
#include <array>
14
15
namespace
sgct
{
16
17
struct
SGCT_EXPORT
ivec2
{
18
constexpr
ivec2
() =
default
;
19
constexpr
ivec2
(
int
x_,
int
y_) :
x
(x_),
y
(y_) {}
20
bool
operator==
(
const
ivec2
&)
const
noexcept
=
default
;
21
22
int
x
= 0;
23
int
y
= 0;
24
};
25
26
struct
SGCT_EXPORT
ivec3
{
27
constexpr
ivec3
() =
default
;
28
constexpr
ivec3
(
int
x_,
int
y_,
int
z_) :
x
(x_),
y
(y_),
z
(z_) {}
29
bool
operator==
(
const
ivec3
&)
const
noexcept
=
default
;
30
31
int
x
= 0;
32
int
y
= 0;
33
int
z
= 0;
34
};
35
36
struct
SGCT_EXPORT
ivec4
{
37
constexpr
ivec4
() =
default
;
38
constexpr
ivec4
(
int
x_,
int
y_,
int
z_,
int
w_) :
x
(x_),
y
(y_),
z
(z_),
w
(w_) {}
39
bool
operator==
(
const
ivec4
&)
const
noexcept
=
default
;
40
41
int
x
= 0;
42
int
y
= 0;
43
int
z
= 0;
44
int
w
= 0;
45
};
46
47
struct
SGCT_EXPORT
vec2
{
48
constexpr
vec2
() =
default
;
49
constexpr
vec2
(
float
x_,
float
y_) :
x
(x_),
y
(y_) {}
50
bool
operator==
(
const
vec2
&)
const
noexcept
=
default
;
51
52
float
x
= 0.f;
53
float
y
= 0.f;
54
};
55
56
struct
SGCT_EXPORT
vec3
{
57
constexpr
vec3
() =
default
;
58
constexpr
vec3
(
float
x_,
float
y_,
float
z_) :
x
(x_),
y
(y_),
z
(z_) {}
59
bool
operator==
(
const
vec3
&)
const
noexcept
=
default
;
60
61
float
x
= 0.f;
62
float
y
= 0.f;
63
float
z
= 0.f;
64
};
65
66
struct
SGCT_EXPORT
vec4
{
67
constexpr
vec4
() =
default
;
68
constexpr
vec4
(
float
x_,
float
y_,
float
z_,
float
w_) :
x
(x_),
y
(y_),
z
(z_),
w
(w_) {}
69
bool
operator==
(
const
vec4
&)
const
noexcept
=
default
;
70
71
float
x
= 0.f;
72
float
y
= 0.f;
73
float
z
= 0.f;
74
float
w
= 0.f;
75
};
76
77
struct
SGCT_EXPORT
quat
{
78
constexpr
quat
() =
default
;
79
constexpr
quat
(
float
x_,
float
y_,
float
z_,
float
w_) :
x
(x_),
y
(y_),
z
(z_),
w
(w_) {}
80
bool
operator==
(
const
quat
&)
const
noexcept
=
default
;
81
82
float
x
= 0.f;
83
float
y
= 0.f;
84
float
z
= 0.f;
85
float
w
= 0.f;
86
};
87
88
// Column-major order matrix
89
struct
SGCT_EXPORT
mat4
{
90
constexpr
mat4
() =
default
;
91
constexpr
mat4
(
float
v) {
92
values
[0 * 4 + 0] = v;
93
values
[0 * 4 + 1] = 0.f;
94
values
[0 * 4 + 2] = 0.f;
95
values
[0 * 4 + 3] = 0.f;
96
values
[1 * 4 + 0] = 0.f;
97
values
[1 * 4 + 1] = v;
98
values
[1 * 4 + 2] = 0.f;
99
values
[1 * 4 + 3] = 0.f;
100
values
[2 * 4 + 0] = 0.f;
101
values
[2 * 4 + 1] = 0.f;
102
values
[2 * 4 + 2] = v;
103
values
[2 * 4 + 3] = 0.f;
104
values
[3 * 4 + 0] = 0.f;
105
values
[3 * 4 + 1] = 0.f;
106
values
[3 * 4 + 2] = 0.f;
107
values
[3 * 4 + 3] = v;
108
}
109
bool
operator==
(
const
mat4
&)
const
noexcept
=
default
;
110
111
std::array<float, 16>
values
;
112
};
113
114
SGCT_EXPORT
mat4
operator*
(
const
mat4
& m1,
const
mat4
& m2);
115
SGCT_EXPORT
vec4
operator*
(
const
mat4
& m,
const
vec4
& v);
116
SGCT_EXPORT
vec3
operator*
(
const
quat
& q,
const
vec3
& v);
117
118
}
// namespace sgct
119
120
#endif
// __SGCT__MATH_H__
sgct
Definition
actions.h:16
sgct::operator*
mat4 operator*(const mat4 &m1, const mat4 &m2)
sgct::ivec2::x
int x
Definition
math.h:22
sgct::ivec2::y
int y
Definition
math.h:23
sgct::ivec2::operator==
bool operator==(const ivec2 &) const noexcept=default
sgct::ivec2::ivec2
constexpr ivec2()=default
sgct::ivec2::ivec2
constexpr ivec2(int x_, int y_)
Definition
math.h:19
sgct::ivec3::operator==
bool operator==(const ivec3 &) const noexcept=default
sgct::ivec3::z
int z
Definition
math.h:33
sgct::ivec3::ivec3
constexpr ivec3(int x_, int y_, int z_)
Definition
math.h:28
sgct::ivec3::ivec3
constexpr ivec3()=default
sgct::ivec3::y
int y
Definition
math.h:32
sgct::ivec3::x
int x
Definition
math.h:31
sgct::ivec4::x
int x
Definition
math.h:41
sgct::ivec4::y
int y
Definition
math.h:42
sgct::ivec4::z
int z
Definition
math.h:43
sgct::ivec4::ivec4
constexpr ivec4()=default
sgct::ivec4::operator==
bool operator==(const ivec4 &) const noexcept=default
sgct::ivec4::w
int w
Definition
math.h:44
sgct::ivec4::ivec4
constexpr ivec4(int x_, int y_, int z_, int w_)
Definition
math.h:38
sgct::mat4
Definition
math.h:89
sgct::mat4::values
std::array< float, 16 > values
Definition
math.h:111
sgct::mat4::operator==
bool operator==(const mat4 &) const noexcept=default
sgct::mat4::mat4
constexpr mat4(float v)
Definition
math.h:91
sgct::mat4::mat4
constexpr mat4()=default
sgct::quat
Definition
math.h:77
sgct::quat::w
float w
Definition
math.h:85
sgct::quat::operator==
bool operator==(const quat &) const noexcept=default
sgct::quat::quat
constexpr quat()=default
sgct::quat::y
float y
Definition
math.h:83
sgct::quat::quat
constexpr quat(float x_, float y_, float z_, float w_)
Definition
math.h:79
sgct::quat::z
float z
Definition
math.h:84
sgct::quat::x
float x
Definition
math.h:82
sgct::vec2::operator==
bool operator==(const vec2 &) const noexcept=default
sgct::vec2::x
float x
Definition
math.h:52
sgct::vec2::vec2
constexpr vec2()=default
sgct::vec2::y
float y
Definition
math.h:53
sgct::vec2::vec2
constexpr vec2(float x_, float y_)
Definition
math.h:49
sgct::vec3
Definition
math.h:56
sgct::vec3::vec3
constexpr vec3(float x_, float y_, float z_)
Definition
math.h:58
sgct::vec3::x
float x
Definition
math.h:61
sgct::vec3::y
float y
Definition
math.h:62
sgct::vec3::operator==
bool operator==(const vec3 &) const noexcept=default
sgct::vec3::vec3
constexpr vec3()=default
sgct::vec3::z
float z
Definition
math.h:63
sgct::vec4
Definition
math.h:66
sgct::vec4::vec4
constexpr vec4()=default
sgct::vec4::z
float z
Definition
math.h:73
sgct::vec4::y
float y
Definition
math.h:72
sgct::vec4::x
float x
Definition
math.h:71
sgct::vec4::vec4
constexpr vec4(float x_, float y_, float z_, float w_)
Definition
math.h:68
sgct::vec4::w
float w
Definition
math.h:74
sgct::vec4::operator==
bool operator==(const vec4 &) const noexcept=default
sgct
math.h
Generated by
1.18.0