SimplexEdge.hpp
Go to the documentation of this file.
1 /*
2  * Original work Copyright (c) 2007-2009 Erin Catto http://www.box2d.org
3  * Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  * 1. The origin of this software must not be misrepresented; you must not
12  * claim that you wrote the original software. If you use this software
13  * in a product, an acknowledgment in the product documentation would be
14  * appreciated but is not required.
15  * 2. Altered source versions must be plainly marked as such, and must not be
16  * misrepresented as being the original software.
17  * 3. This notice may not be removed or altered from any source distribution.
18  */
19 
20 #ifndef PLAYRHO_COLLISION_SIMPLEXEDGE_HPP
21 #define PLAYRHO_COLLISION_SIMPLEXEDGE_HPP
22 
23 #include <PlayRho/Common/Math.hpp>
25 
26 namespace playrho {
27 namespace d2 {
28 
37 {
38 public:
40  SimplexEdge() = default;
41 
43  PLAYRHO_CONSTEXPR inline SimplexEdge(const SimplexEdge& copy) = default;
44 
51  Length2 pB, VertexCounter iB) noexcept;
52 
54  PLAYRHO_CONSTEXPR inline auto GetPointA() const noexcept { return m_wA; }
55 
57  PLAYRHO_CONSTEXPR inline auto GetPointB() const noexcept { return m_wB; }
58 
60  PLAYRHO_CONSTEXPR inline auto GetIndexA() const noexcept { return std::get<0>(m_indexPair); }
61 
63  PLAYRHO_CONSTEXPR inline auto GetIndexB() const noexcept { return std::get<1>(m_indexPair); }
64 
66  PLAYRHO_CONSTEXPR inline auto GetIndexPair() const noexcept { return m_indexPair; }
67 
68 private:
69  Length2 m_wA;
70  Length2 m_wB;
71  IndexPair m_indexPair;
72 };
73 
75  Length2 pB, VertexCounter iB) noexcept:
76  m_wA{pA}, m_wB{pB}, m_indexPair{iA, iB}
77 {
78  // Intentionally empty.
79 }
80 
84 {
85  return sv.GetPointB() - sv.GetPointA();
86 }
87 
89 PLAYRHO_CONSTEXPR inline bool operator== (const SimplexEdge& lhs, const SimplexEdge& rhs) noexcept
90 {
91  return (lhs.GetPointA() == rhs.GetPointA())
92  && (lhs.GetPointB() == rhs.GetPointB())
93  && (lhs.GetIndexPair() == rhs.GetIndexPair());
94 }
95 
97 PLAYRHO_CONSTEXPR inline bool operator!= (const SimplexEdge& lhs, const SimplexEdge& rhs) noexcept
98 {
99  return !(lhs == rhs);
100 }
101 
102 } // namespace d2
103 } // namespace playrho
104 
105 #endif // PLAYRHO_COLLISION_SIMPLEXEDGE_HPP