@@ -30,118 +30,29 @@ and Lorenzo Moneta
30
30
class MnParabola {
31
31
32
32
public:
33
- /* *
34
-
35
- Constructor that initializes the parabola with its three parameters.
36
-
37
- @param a the coefficient of the quadratic term
38
- @param b the coefficient of the linear term
39
- @param c the constant
40
-
41
- */
42
-
33
+ // / Constructor that initializes the parabola with its three parameters.
34
+ // /
35
+ // / @param a the coefficient of the quadratic term.
36
+ // / @param b the coefficient of the linear term.
37
+ // / @param c the constant.
43
38
MnParabola (double a, double b, double c) : fA (a), fB (b), fC (c) {}
44
39
45
- /* *
46
-
47
- Evaluates the parabola a the point x.
48
-
49
- @param x the coordinate where the parabola needs to be evaluated.
50
-
51
- @return the y coordinate of the parabola corresponding to x.
52
-
53
- */
54
-
40
+ // / Evaluates the parabola a the point x.
55
41
double Y (double x) const { return (fA * x * x + fB * x + fC ); }
56
42
57
- /* *
58
-
59
- Calculates the bigger of the two x values corresponding to the
60
- given y Value.
61
-
62
- <p>
63
-
64
- ???????!!!!!!!!! And when there is none?? it looks like it will
65
- crash?? what is sqrt (-1.0) ?
66
-
67
- @param y the y Value for which the x Value is to be calculated.
68
-
69
- @return the bigger one of the two corresponding values.
70
-
71
- */
72
-
73
- // ok, at first glance it does not look like the formula for the quadratic
74
- // equation, but it is! ;-)
75
- double X_pos (double y) const { return (std::sqrt (y / fA + Min () * Min () - fC / fA ) + Min ()); }
76
- // maybe it is worth to check the performance improvement with the below formula??
77
- // double X_pos(double y) const {return (std::sqrt(y/fA + fB*fB/(4.*fA*fA) - fC/fA) - fB/(2.*fA));}
78
-
79
- /* *
80
-
81
- Calculates the smaller of the two x values corresponding to the
82
- given y Value.
83
-
84
- <p>
85
-
86
- ???????!!!!!!!!! And when there is none?? it looks like it will
87
- crash?? what is sqrt (-1.0) ?
88
-
89
- @param y the y Value for which the x Value is to be calculated.
90
-
91
- @return the smaller one of the two corresponding values.
92
-
93
- */
94
-
95
- double X_neg (double y) const { return (-std::sqrt (y / fA + Min () * Min () - fC / fA ) + Min ()); }
96
-
97
- /* *
98
-
99
- Calculates the x coordinate of the Minimum of the parabola.
100
-
101
- @return x coordinate of the Minimum.
102
-
103
- */
104
-
43
+ // / Calculate the x coordinate of the Minimum of the parabola.
105
44
double Min () const { return -fB / (2 . * fA ); }
106
45
107
- /* *
108
-
109
- Calculates the y coordinate of the Minimum of the parabola.
110
-
111
- @return y coordinate of the Minimum.
112
-
113
- */
114
-
46
+ // / Calculate the y coordinate of the Minimum of the parabola.
115
47
double YMin () const { return (-fB * fB / (4 . * fA ) + fC ); }
116
48
117
- /* *
118
-
119
- Accessor to the coefficient of the quadratic term.
120
-
121
- @return the coefficient of the quadratic term.
122
-
123
- */
124
-
49
+ // / Get the coefficient of the quadratic term.
125
50
double A () const { return fA ; }
126
51
127
- /* *
128
-
129
- Accessor to the coefficient of the linear term.
130
-
131
- @return the coefficient of the linear term.
132
-
133
- */
134
-
52
+ // / Get the coefficient of the linear term.
135
53
double B () const { return fB ; }
136
54
137
- /* *
138
-
139
- Accessor to the coefficient of the constant term.
140
-
141
- @return the coefficient of the constant term.
142
-
143
- */
144
-
55
+ // / Get the coefficient of the constant term.
145
56
double C () const { return fC ; }
146
57
147
58
private:
0 commit comments