Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TVector2.ipp
Go to the documentation of this file.
1#pragma once
2
3#include "Math/TVector2.h"
4#include "Math/math.h"
5
6#include <Common/assertion.h>
7#include <Common/utility.h>
8
9#include <cmath>
10#include <algorithm>
11#include <type_traits>
12#include <array>
13
14namespace ph::math
15{
16
17template<typename T>
18inline TVector2<T>::TVector2(const T vx, const T vy) :
19 Base(std::array<T, 2>{vx, vy})
20{}
21
22template<typename T>
23template<typename U>
24inline TVector2<T>::TVector2(const TVector2<U>& other) :
25 TVector2(static_cast<T>(other[0]), static_cast<T>(other[1]))
26{}
27
28template<typename T>
29template<typename U>
31{
32 return TVector2<U>(
33 lossless_cast<U>(m[0]),
34 lossless_cast<U>(m[1]));
35}
37template<typename T>
38inline T& TVector2<T>::x()
40 return m[0];
41}
43template<typename T>
44inline T& TVector2<T>::y()
46 return m[1];
48
49template<typename T>
50inline const T& TVector2<T>::x() const
52 return m[0];
53}
54
55template<typename T>
56inline const T& TVector2<T>::y() const
57{
58 return m[1];
59}
60
61template<typename T>
62inline T& TVector2<T>::u()
63{
64 return m[0];
65}
66
67template<typename T>
68inline T& TVector2<T>::v()
69{
70 return m[1];
71}
72
73template<typename T>
74inline const T& TVector2<T>::u() const
75{
76 return m[0];
77}
78
79template<typename T>
80inline const T& TVector2<T>::v() const
81{
82 return m[1];
83}
84
85}// end namespace ph::math
Represents a 2-D vector.
Definition TVector2.h:19
T & x()
Definition TVector2.ipp:38
TVector2< U > losslessCast() const
Definition TVector2.ipp:30
T & u()
Definition TVector2.ipp:62
T & v()
Definition TVector2.ipp:68
T & y()
Definition TVector2.ipp:44
Miscellaneous math utilities.
Math functions and utilities.
Definition TransformInfo.h:10
Definition TAABB2D.h:96