Pathfinder
Public Member Functions | Public Attributes | List of all members
Pathfinder::Line2 Struct Reference

This struct represents a vertical 2D line or a line of the form y = mx + b. More...

#include <Line2.h>

Collaboration diagram for Pathfinder::Line2:

Public Member Functions

 Line2 (const float &m, const float &b)
 A constructor that creates a non-vertical line from the two parameters that describe a 2D line. More...
 
 Line2 (Geometry::Vec2 &u, Geometry::Vec2 &v)
 A constructor that creates a line from two points. More...
 
boost::optional< float > eval (const float &x)
 Evaluate the line function for a given x. More...
 

Public Attributes

boost::optional< float > m
 The slope of the line. More...
 
boost::optional< float > b
 The y-intersect of the line. More...
 
boost::optional< float > xpos
 The x value of a vertical line. More...
 
bool vertical
 Indicate if this line is vertical. More...
 

Detailed Description

This struct represents a vertical 2D line or a line of the form y = mx + b.

Constructor & Destructor Documentation

◆ Line2() [1/2]

Pathfinder::Line2::Line2 ( const float &  m,
const float &  b 
)

A constructor that creates a non-vertical line from the two parameters that describe a 2D line.

Parameters
mThe slope of the line.
bThe y-intercept of the line.

◆ Line2() [2/2]

Pathfinder::Line2::Line2 ( Geometry::Vec2 &  u,
Geometry::Vec2 &  v 
)

A constructor that creates a line from two points.

The necessary parameters are calculated from the two given points.

Parameters
uThe first point.
vThe second point.

Member Function Documentation

◆ eval()

boost::optional< float > Pathfinder::Line2::eval ( const float &  x)

Evaluate the line function for a given x.

Parameters
xThe point at where the line function shall be evaluated.
Returns
Return the corresponding y value to the given input if the line is not vertical. Return boost::none if the line is vertical.

Member Data Documentation

◆ b

boost::optional<float> Pathfinder::Line2::b

The y-intersect of the line.

◆ m

boost::optional<float> Pathfinder::Line2::m

The slope of the line.

◆ vertical

bool Pathfinder::Line2::vertical

Indicate if this line is vertical.

◆ xpos

boost::optional<float> Pathfinder::Line2::xpos

The x value of a vertical line.


The documentation for this struct was generated from the following files: