Spinning Topp Logo BlackTopp Studios
inc
linesegment.cpp
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_cpp
41 #define _linesegment_cpp
42 
43 #include "linesegment.h"
44 #include "MathTools/mathtools.h"
45 
46 namespace Mezzanine
47 {
48  ///////////////////////////////////////////////////////////////////////////////
49  // LineSegment2D
50 
51  ///////////////////////////////////////////////////////////////////////////////
52  // Construction and Destruction
53 
55  { }
56 
58  PointA(A),
59  PointB(B)
60  { }
61 
63  PointA(Other.PointA),
64  PointB(Other.PointB)
65  { }
66 
67  ///////////////////////////////////////////////////////////////////////////////
68  // Utility
69 
71  { return MathTools::Intersects(*this,Other); }
72 
73  ///////////////////////////////////////////////////////////////////////////////
74  // LineSegment3D
75 
76  ///////////////////////////////////////////////////////////////////////////////
77  // Construction and Destruction
78 
80  { }
81 
83  PointA(A),
84  PointB(B)
85  { }
86 
88  PointA(Other.PointA),
89  PointB(Other.PointB)
90  { }
91 
92  ///////////////////////////////////////////////////////////////////////////////
93  // Utility
94 
96  {
97  return ( ( this->PointA.SquaredDistance( Other.PointA ) < 1e-8 && this->PointB.SquaredDistance( Other.PointB ) < 1e-8 ) ||
98  ( this->PointA.SquaredDistance( Other.PointB ) < 1e-8 && this->PointB.SquaredDistance( Other.PointA ) < 1e-8 ) );
99  }
100 
102  {
103  if( Vector3LengthCompare()(this->PointB,this->PointA) )
104  return LineSegment3D(this->PointB,this->PointA);
105  return *this;
106  }
107 }//Mezzanine
108 
109 #endif
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
Boole EpsilonEquivalent(const LineSegment3D &Other) const
Equality comparison with some slack.
Definition: linesegment.cpp:95
IntersectionTestResult Intersects(const LineSegment2D &Other) const
Gets whether or not another line segment intersects with this one.
Definition: linesegment.cpp:70
LineSegment3D()
Blank constructor.
Definition: linesegment.cpp:79
A compare fuctor that uses vector length.
Definition: vector3.h:524
LineSegment2D()
Blank constructor.
Definition: linesegment.cpp:54
std::pair< Boole, Vector2 > IntersectionTestResult
This is a type used for the return of a intersection test.
Definition: linesegment.h:58
Real SquaredDistance(const Vector3 &OtherVec) const
Gets the squared distance between this and another vector.
Definition: vector3.cpp:454
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
LineSegment3D GetOrderedCopy() const
Gets a copy of this line segment with it's members ordered by length.
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
A geometry math class for expressing a line connecting 2 points in 2D space.
Definition: linesegment.h:52