Locus No Pilotus
Project of four first grade MIPT DAFE/RSE students (for engineering practical work in the second semester) in Qt C++
Loading...
Searching...
No Matches
math::LinearFunction Struct Reference

Прямая вида ax+by+c=0. More...

#include <obstacles.h>

Public Member Functions

 LinearFunction (const lib::Point &point1, const lib::Point &point2)
 
 LinearFunction (double a, double b, double c)
 
bool operator== (const LinearFunction &other) const
 
double Substitute (const lib::Point &p) const
 

Public Attributes

double a_coef
 
double b_coef
 
double c_coef
 

Detailed Description

Прямая вида ax+by+c=0.

Constructor & Destructor Documentation

◆ LinearFunction() [1/2]

math::LinearFunction::LinearFunction ( double a,
double b,
double c )
inline
19 : a_coef{a}, b_coef{b}, c_coef{c} {}
double a_coef
Definition obstacles.h:32
double c_coef
Definition obstacles.h:32
double b_coef
Definition obstacles.h:32

◆ LinearFunction() [2/2]

math::LinearFunction::LinearFunction ( const lib::Point & point1,
const lib::Point & point2 )
inline
21 {
22 a_coef = point2.y - point1.y;
23 b_coef = -(point2.x - point1.x);
24 c_coef =
25 (point2.x - point1.x) * point1.y - (point2.y - point1.y) * point1.x;
26 }
double y
Definition point.h:18
double x
Definition point.h:17

Member Function Documentation

◆ operator==()

bool math::LinearFunction::operator== ( const LinearFunction & other) const
inline
34 {
35 double proportion = ((std::abs(a_coef) >= precision) &&
36 (std::abs(other.a_coef) >= precision))
37 ? other.a_coef / a_coef
38 : other.b_coef / b_coef;
39 return (std::abs(other.a_coef - proportion * a_coef) < precision) &&
40 (std::abs(other.b_coef - proportion * b_coef) < precision) &&
41 (std::abs(other.c_coef - proportion * c_coef) < precision);
42 }

◆ Substitute()

double math::LinearFunction::Substitute ( const lib::Point & p) const
inline
28 {
29 return a_coef * p.x + b_coef * p.y + c_coef;
30 }
Here is the caller graph for this function:

Member Data Documentation

◆ a_coef

double math::LinearFunction::a_coef

◆ b_coef

double math::LinearFunction::b_coef

◆ c_coef

double math::LinearFunction::c_coef

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