SPARK
0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
Vector2.h
1
#pragma once
2
3
namespace
spark::math
4
{
5
template
<
typename
T>
6
constexpr
Vector2<T>::Vector2
()
7
: details::Vector<
Vector2
, T, 2>({std::ref(x), std::ref(y)}) {}
8
9
template
<
typename
T>
10
constexpr
Vector2<T>::Vector2
(T x_value, T y_value) noexcept
11
:
details::Vector<Vector2, T, 2>
({std::ref(x), std::ref(y)}), x(x_value), y(y_value) {}
12
13
template
<
typename
T>
14
constexpr
Vector2<T>::Vector2
(
const
Vector2& other)
15
: details::Vector<Vector2, T, 2>({std::ref(x), std::ref(y)}), x(other.x), y(other.y) {}
16
17
template
<
typename
T>
18
constexpr
Vector2<T>::Vector2
(
Vector2
&& other) noexcept
19
:
details::Vector<Vector2, T, 2>
({std::ref(x), std::ref(y)}), x(std::move(other.x)), y(std::move(other.y)) {}
20
21
template
<
typename
T>
22
constexpr
Vector2<T>& Vector2<T>::operator=(
const
Vector2& other)
23
{
24
if
(
this
== &other)
25
return
*
this
;
26
27
x = other.x;
28
y = other.y;
29
return
*
this
;
30
}
31
32
template
<
typename
T>
33
constexpr
Vector2<T>
&
Vector2<T>::operator=
(
Vector2
&& other)
noexcept
34
{
35
if
(
this
== &other)
36
return
*
this
;
37
38
x = std::move(other.x);
39
y = std::move(other.y);
40
return
*
this
;
41
}
42
43
template
<
typename
T>
44
template
<
typename
To>
45
constexpr
Vector2<To>
Vector2<T>::castTo
() const noexcept
46
{
47
return
Vector2<To>
(
static_cast<
To
>
(x),
static_cast<
To
>
(y));
48
}
49
}
spark::math::Vector2
A vector with two components.
Definition
Vector2.h:13
spark::math::Vector2::castTo
constexpr Vector2< To > castTo() const noexcept
Casts all components of the Vector2 to the type To.
Definition
Vector2.h:45
spark::math::Vector2::Vector2
constexpr Vector2()
Initializes a new Vector2 with all components to their default value.
Definition
Vector2.h:6
spark::math::details::Vector
Definition
Vector.h:12
sources
spark
math
include
spark
math
impl
Vector2.h
Generated by
1.11.0