35 LineEquation::LineEquation() {
37 p_slopeDefined =
false;
38 p_interceptDefined =
false;
48 LineEquation::LineEquation(
double x1,
double y1,
double x2,
double y2) {
50 p_slopeDefined =
false;
51 p_interceptDefined =
false;
67 void LineEquation::AddPoint(
double x,
double y) {
69 std::string msg =
"Line equation is already defined with 2 points";
74 if(Points() == 2) p_defined =
true;
82 double LineEquation::Slope() {
84 std::string msg =
"Line equation undefined: 2 points are required";
87 else if(p_x[0] == p_x[1]) {
88 std::string msg =
"Points have identical independent variables -- no slope";
91 else if(!p_slopeDefined) {
92 p_slope = (p_y[0] - p_y[1]) / (p_x[0] - p_x[1]);
93 p_slopeDefined =
true;
103 double LineEquation::Intercept() {
105 std::string msg =
"Line equation undefined: 2 points are required";
108 else if(p_x[0] == p_x[1]) {
109 std::string msg =
"Points have identical independent variables -- no intercept";
112 else if(!p_interceptDefined) {
113 p_intercept = p_y[0] - Slope() * p_x[0];
114 p_interceptDefined =
true;
Namespace for the standard library.
#define _FILEINFO_
Macro for the filename and line number.
Container for a intercept condition.
Namespace for ISIS/Bullet specific routines.