Spinning Topp Logo BlackTopp Studios
inc
linesegment.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 _linesegment_h
41 #define _linesegment_h
42 
43 #include "vector2.h"
44 #include "vector3.h"
45 
46 namespace Mezzanine
47 {
48  ///////////////////////////////////////////////////////////////////////////////
49  /// @brief A geometry math class for expressing a line connecting 2 points in 2D space.
50  /// @details
51  ///////////////////////////////////////
53  {
54  public:
55  /// @brief This is a type used for the return of a intersection test.
56  /// @details This type provides more verbose return data that can be used for further tests. @n @n
57  /// The first member stores whether or not there was a hit. The second member stores the point in 2D space where the segments intersect.
58  typedef std::pair<Boole,Vector2> IntersectionTestResult;
59 
60  ///////////////////////////////////////////////////////////////////////////////
61  // Public Data Members
62 
63  /// @brief The first point defining the segment.
65  /// @brief The second point defining the segment.
67 
68  ///////////////////////////////////////////////////////////////////////////////
69  // Construction and Destruction
70 
71  /// @brief Blank constructor.
72  LineSegment2D();
73  /// @brief Descriptive constructor.
74  /// @param A The first point defining the segment.
75  /// @param B The second point defining the segment.
76  LineSegment2D(const Vector2& A, const Vector2& B);
77  /// @brief Copy constructor.
78  /// @param Other The other line segment to copy from.
79  LineSegment2D(const LineSegment2D& Other);
80 
81  ///////////////////////////////////////////////////////////////////////////////
82  // Utility
83 
84  /// @brief Gets whether or not another line segment intersects with this one.
85  /// @param Other The other line segment to compare with.
86  /// @return Returns true if this line segment intersects with the other segment, false otherwise.
87  IntersectionTestResult Intersects(const LineSegment2D& Other) const;
88  };//LineSegment2D
89 
90  ///////////////////////////////////////////////////////////////////////////////
91  /// @brief A geometry math class for expressing a line connecting 2 points in 3D space.
92  /// @details
93  ///////////////////////////////////////
95  {
96  public:
97  ///////////////////////////////////////////////////////////////////////////////
98  // Public Data Members
99 
100  /// @brief The first point defining the segment.
102  /// @brief The second point defining the segment.
104 
105  ///////////////////////////////////////////////////////////////////////////////
106  // Construction and Destruction
107 
108  /// @brief Blank constructor.
109  LineSegment3D();
110  /// @brief Descriptive constructor.
111  /// @param A The first point defining the segment.
112  /// @param B The second point defining the segment.
113  LineSegment3D(const Vector3& A, const Vector3& B);
114  /// @brief Copy constructor.
115  /// @param Other The other line segment to copy from.
116  LineSegment3D(const LineSegment3D& Other);
117 
118  ///////////////////////////////////////////////////////////////////////////////
119  // Utility
120 
121  /// @brief Equality comparison with some slack.
122  /// @param Other The other LineSegment3D to compare with.
123  /// @return Returns true if the two line segments are equal within the epsilon.
124  Boole EpsilonEquivalent(const LineSegment3D& Other) const;
125  /// @brief Gets a copy of this line segment with it's members ordered by length.
126  /// @return Returns a LineSegment3D with the same values as this, but with PointA guarenteed to be the vector with the shorter length.
127  LineSegment3D GetOrderedCopy() const;
128  };//LineSegment3D
129 }//Mezzanine
130 
131 #endif
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
std::pair< Boole, Vector2 > IntersectionTestResult
This is a type used for the return of a intersection test.
Definition: linesegment.h:58
Vector2 PointA
The first point defining the segment.
Definition: linesegment.h:64
A geometry math class for expressing a line connecting 2 points in 3D space.
Definition: linesegment.h:94
Vector3 PointB
The second point defining the segment.
Definition: linesegment.h:103
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
Vector3 PointA
The first point defining the segment.
Definition: linesegment.h:101
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
Vector2 PointB
The second point defining the segment.
Definition: linesegment.h:66
A geometry math class for expressing a line connecting 2 points in 2D space.
Definition: linesegment.h:52