Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TVector2.h
Go to the documentation of this file.
1#pragma once
2
4#include "Math/math_fwd.h"
5#include "Math/constant.h"
6#include "Math/hash.h"
7
8#include <Common/Utility/string_utils.h>
9
10#include <functional>
11
12namespace ph::math
13{
14
17template<typename T>
18class TVector2 final : public TVectorNBase<TVector2<T>, T, 2>
19{
20private:
21 using Base = TVectorNBase<TVector2<T>, T, 2>;
22
23protected:
24 using Base::m;
25
26public:
27 inline TVector2() = default;
28 inline TVector2(const TVector2& other) = default;
29 inline TVector2(TVector2&& other) = default;
30 inline TVector2& operator = (const TVector2& rhs) = default;
31 inline TVector2& operator = (TVector2&& rhs) = default;
32 inline ~TVector2() = default;
33
34 using Base::Base;
35
36 TVector2(T vx, T vy);
37
38 template<typename U>
39 explicit TVector2(const TVector2<U>& other);
40
41 template<typename U>
43
44 T& x();
45 T& y();
46 const T& x() const;
47 const T& y() const;
48
49 T& u();
50 T& v();
51 const T& u() const;
52 const T& v() const;
53};
54
55}// end namespace ph::math
56
57template<typename T>
59
60namespace std
61{
62
63template<typename T>
64struct hash<ph::math::TVector2<T>>
65{
66 std::size_t operator () (const ph::math::TVector2<T>& vec2) const
67 {
68 return ph::math::murmur3_32(vec2, 0);
69 }
70};
71
72}// end namespace std
73
74#include "Math/TVector2.ipp"
PH_DEFINE_INLINE_TO_STRING_FORMATTER_TEMPLATE(ph::math::TVector2< T >)
Represents a 2-D vector.
Definition TVector2.h:19
T & x()
Definition TVector2.ipp:38
TVector2< U > losslessCast() const
Definition TVector2.ipp:30
TVector2 & operator=(const TVector2 &rhs)=default
TVector2(const TVector2 &other)=default
TVector2(TVector2 &&other)=default
T & u()
Definition TVector2.ipp:62
T & v()
Definition TVector2.ipp:68
T & y()
Definition TVector2.ipp:44
Definition TVectorNBase.h:14
std::array< T, N > m
Definition TArithmeticArrayBase.h:217
Math functions and utilities.
Definition TransformInfo.h:10
uint32 murmur3_32(const T &data, uint32 seed)
Generate 32-bit hash values using MurmurHash3. Note that there are no collisions when T has <= 32 bit...
Definition hash.ipp:119
The root for all renderer implementations.
Definition EEngineProject.h:6
Definition TAABB2D.h:96