1 |
< |
/* |
1 |
> |
/* |
2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
55 |
|
|
56 |
|
namespace oopse { |
57 |
|
|
58 |
< |
/** |
59 |
< |
* @class PolynomialBendType PolynomialBendType.hpp "types/PolynomialBendType.hpp" |
60 |
< |
* @todo documentation |
61 |
< |
*/ |
62 |
< |
class PolynomialBendType : public BendType{ |
58 |
> |
/** |
59 |
> |
* @class PolynomialBendType PolynomialBendType.hpp "types/PolynomialBendType.hpp" |
60 |
> |
* @todo documentation |
61 |
> |
*/ |
62 |
> |
class PolynomialBendType : public BendType{ |
63 |
|
|
64 |
< |
public: |
65 |
< |
PolynomialBendType(double theta) : BendType(theta) {} |
64 |
> |
public: |
65 |
> |
PolynomialBendType(double theta) : BendType(theta) {} |
66 |
|
|
67 |
< |
void setCoefficient(int power, double coefficient) { |
68 |
< |
polynomial_.setCoefficient(power, coefficient); |
69 |
< |
} |
67 |
> |
void setCoefficient(int power, double coefficient) { |
68 |
> |
polynomial_.setCoefficient(power, coefficient); |
69 |
> |
} |
70 |
|
|
71 |
< |
double getCoefficient(int power) { |
72 |
< |
return polynomial_.getCoefficient(power); |
73 |
< |
} |
71 |
> |
double getCoefficient(int power) { |
72 |
> |
return polynomial_.getCoefficient(power); |
73 |
> |
} |
74 |
|
|
75 |
< |
void calcForce(double theta, double & V, double & dVdr) { |
76 |
< |
double delta = theta - theta0_; |
77 |
< |
V = polynomial_.evaluate(delta); |
78 |
< |
dVdr = polynomial_.evaluateDerivative(delta); |
75 |
> |
void calcForce(double theta, double & V, double & dVdr) { |
76 |
> |
double delta = theta - theta0_; |
77 |
> |
V = polynomial_.evaluate(delta); |
78 |
> |
dVdr = polynomial_.evaluateDerivative(delta); |
79 |
|
|
80 |
< |
} |
80 |
> |
} |
81 |
|
|
82 |
< |
friend std::ostream& operator <<(std::ostream& os, PolynomialBendType& pbt); |
82 |
> |
friend std::ostream& operator <<(std::ostream& os, PolynomialBendType& pbt); |
83 |
|
|
84 |
< |
private: |
84 |
> |
private: |
85 |
|
|
86 |
< |
DoublePolynomial polynomial_; |
87 |
< |
}; |
86 |
> |
DoublePolynomial polynomial_; |
87 |
> |
}; |
88 |
|
|
89 |
< |
std::ostream& operator <<(std::ostream& os, PolynomialBendType& pbt) { |
89 |
> |
std::ostream& operator <<(std::ostream& os, PolynomialBendType& pbt) { |
90 |
|
DoublePolynomial::const_iterator i; |
91 |
|
|
92 |
|
i = pbt.polynomial_.begin(); |
93 |
|
|
94 |
|
if (i == pbt.polynomial_.end()) { |
95 |
< |
os << "This PolynomialBendType contains nothing" << std::endl; |
96 |
< |
return os; |
95 |
> |
os << "This PolynomialBendType contains nothing" << std::endl; |
96 |
> |
return os; |
97 |
|
} |
98 |
|
|
99 |
|
os << "This PolynomialBendType contains below terms:" << std::endl; |
100 |
|
|
101 |
|
while(true){ |
102 |
< |
os << i->second << "*" << "(theta - " << pbt.getTheta() << ")" << "^" << i->first; |
102 |
> |
os << i->second << "*" << "(theta - " << pbt.getTheta() << ")" << "^" << i->first; |
103 |
|
|
104 |
< |
if (++i == pbt.polynomial_.end()) { |
105 |
< |
//if we reach the end of the polynomial pair, write out a newline and then escape the loop |
106 |
< |
os << std::endl; |
107 |
< |
break; |
108 |
< |
} else { |
109 |
< |
//otherwise, write out a "+" |
110 |
< |
os << " + "; |
111 |
< |
} |
104 |
> |
if (++i == pbt.polynomial_.end()) { |
105 |
> |
//if we reach the end of the polynomial pair, write out a newline and then escape the loop |
106 |
> |
os << std::endl; |
107 |
> |
break; |
108 |
> |
} else { |
109 |
> |
//otherwise, write out a "+" |
110 |
> |
os << " + "; |
111 |
> |
} |
112 |
|
} |
113 |
|
|
114 |
|
return os; |
115 |
< |
} |
115 |
> |
} |
116 |
|
|
117 |
|
|
118 |
|
} //end namespace oopse |