Pathfinder
Line2.h
Go to the documentation of this file.
1 
10 #ifndef LINE2_H
11 #define LINE2_H
12 
13 #include <boost/optional.hpp>
14 
15 #include "Using.h"
16 #include "Geometry/Vec2.h"
17 
18 namespace Pathfinder {
19 
24  struct Line2 {
25 
29  boost::optional<float> m;
30 
31 
35  boost::optional<float> b;
36 
37 
41  boost::optional<float> xpos;
42 
43 
47  bool vertical;
48 
49 
57  Line2(
58  const float& m,
59  const float& b
60  );
61 
62 
71  Line2(
72  Geometry::Vec2& u,
73  Geometry::Vec2& v
74  );
75 
76 
86  boost::optional<float>
87  eval(
88  const float& x
89  );
90 
91  };
92 
93 
103  boost::optional<float>
105  const Line2& a,
106  const Line2& b
107  );
108 
109 }
110 
111 #endif
Definition: Using.h:32
bool vertical
Indicate if this line is vertical.
Definition: Line2.h:47
boost::optional< float > line2Intersection(const Line2 &a, const Line2 &b)
Compute the x value of the intersection of two lines.
Definition: Line2.cpp:40
boost::optional< float > m
The slope of the line.
Definition: Line2.h:29
boost::optional< float > xpos
The x value of a vertical line.
Definition: Line2.h:41
boost::optional< float > b
The y-intersect of the line.
Definition: Line2.h:35
Definition: AABB.cpp:21
Line2(const float &m, const float &b)
A constructor that creates a non-vertical line from the two parameters that describe a 2D line...
Definition: Line2.cpp:14
This struct represents a vertical 2D line or a line of the form y = mx + b.
Definition: Line2.h:24
boost::optional< float > eval(const float &x)
Evaluate the line function for a given x.
Definition: Line2.cpp:31
This file provides using and enum declarations.