Spinning Topp Logo BlackTopp Studios
inc
triangle.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _triangle_h
41 #define _triangle_h
42 
43 #include "vector2.h"
44 #include "vector3.h"
45 #include "linesegment.h"
46 
47 namespace Mezzanine
48 {
49  ///////////////////////////////////////////////////////////////////////////////
50  /// @brief A geometry math class for expressing a triangle in 2D space.
51  /// @details
52  ///////////////////////////////////////
54  {
55  public:
56  ///////////////////////////////////////////////////////////////////////////////
57  // Public Data Members
58 
59  /// @brief The first point in space making the triangle.
61  /// @brief The second point in space making the triangle.
63  /// @brief The third point in space making the triangle.
65 
66  ///////////////////////////////////////////////////////////////////////////////
67  // Construction and Destruction
68 
69  /// @brief Blank constructor.
70  Triangle2D();
71  /// @brief Descriptive constructor.
72  /// @param A The first point in space making the triangle.
73  /// @param B The second point in space making the triangle.
74  /// @param C The third point in space making the triangle.
75  Triangle2D(const Vector2& A, const Vector2& B, const Vector2& C);
76 
77  ///////////////////////////////////////////////////////////////////////////////
78  // Utility
79 
80  /// @brief Gets the point in this triangle corresponding to the specified index.
81  /// @exception If the index passed in is greater than 2, a PARAMETERS_RANGE_EXCEPTION will be thrown.
82  /// @param Index The index of the point to retrieve.
83  /// @return Returns a reference to a Vector2 containing the position of the specified point.
84  Vector2& operator[](const Whole& Index);
85  /// @brief Gets the point in this triangle corresponding to the specified index.
86  /// @exception If the index passed in is greater than 2, a PARAMETERS_RANGE_EXCEPTION will be thrown.
87  /// @param Index The index of the point to retrieve.
88  /// @return Returns a const reference to a Vector2 containing the position of the specified point.
89  const Vector2& operator[](const Whole& Index) const;
90  };//Triangle2D
91 
92  ///////////////////////////////////////////////////////////////////////////////
93  /// @brief A geometry math class for expressing a triangle in 3D space.
94  /// @details
95  ///////////////////////////////////////
97  {
98  public:
99  ///////////////////////////////////////////////////////////////////////////////
100  // Public Data Members
101 
102  /// @brief The first point in space making the triangle.
104  /// @brief The second point in space making the triangle.
106  /// @brief The third point in space making the triangle.
108 
109  ///////////////////////////////////////////////////////////////////////////////
110  // Construction and Destruction
111 
112  /// @brief Blank constructor.
113  Triangle3D();
114  /// @brief Descriptive constructor.
115  /// @param A The first point in space making the triangle.
116  /// @param B The second point in space making the triangle.
117  /// @param C The third point in space making the triangle.
118  Triangle3D(const Vector3& A, const Vector3& B, const Vector3& C);
119 
120  ///////////////////////////////////////////////////////////////////////////////
121  // Utility
122 
123  /// @brief Gets the overlap of two triangles.
124  /// @param Other The other triangle to compare with.
125  /// @return Returns a line segment expressing the length where the two triangles overlap, or a zero'd out line segment if there is no overlap.
126  LineSegment3D GetOverlap(const Triangle3D& Other) const;
127 
128  /// @brief Gets the point in this triangle corresponding to the specified index.
129  /// @exception If the index passed in is greater than 2, a PARAMETERS_RANGE_EXCEPTION will be thrown.
130  /// @param Index The index of the point to retrieve.
131  /// @return Returns a reference to a Vector2 containing the position of the specified point.
132  Vector3& operator[](const Whole& Index);
133  /// @brief Gets the point in this triangle corresponding to the specified index.
134  /// @exception If the index passed in is greater than 2, a PARAMETERS_RANGE_EXCEPTION will be thrown.
135  /// @param Index The index of the point to retrieve.
136  /// @return Returns a const reference to a Vector2 containing the position of the specified point.
137  const Vector3& operator[](const Whole& Index) const;
138  };//Triangle3D
139 }//Mezzanine
140 
141 #endif
Vector3 PointA
The first point in space making the triangle.
Definition: triangle.h:103
A geometry math class for expressing a triangle in 2D space.
Definition: triangle.h:53
A geometry math class for expressing a line connecting 2 points in 3D space.
Definition: linesegment.h:94
Vector2 PointC
The third point in space making the triangle.
Definition: triangle.h:64
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
A geometry math class for expressing a triangle in 3D space.
Definition: triangle.h:96
Vector3 PointC
The third point in space making the triangle.
Definition: triangle.h:107
Vector3 PointB
The second point in space making the triangle.
Definition: triangle.h:105
Vector2 PointB
The second point in space making the triangle.
Definition: triangle.h:62
This is used to represent a point in space, or a vector through space.
Definition: vector3.h:77
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
Vector2 PointA
The first point in space making the triangle.
Definition: triangle.h:60