added LinearSolver to util/Solver module; added shapes/Plane module
git-svn-id: svn://anubis/fart/trunk@59 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
1 parent
e34bdf0d71
commit
7a4bb7dbc2
4 files changed
+110
No files matched your search
@@ -13,6 +13,40 @@ Solver::Solver(double a, double b, double c, double d, double e)
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* LinearSolver methods *
|
||||
*************************************************************************/
|
||||
LinearSolver::LinearSolver(double a, double b)
|
||||
: Solver(a, b)
|
||||
{
|
||||
}
|
||||
|
||||
/* solve a linear equation */
|
||||
Solver::Result LinearSolver::solve()
|
||||
{
|
||||
/* equation ax + b = 0 */
|
||||
Result res;
|
||||
if (a == 0.0)
|
||||
{
|
||||
if (b == 0.0)
|
||||
{
|
||||
res.numResults = 1;
|
||||
res.results[0] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
res.numResults = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.numResults = 1;
|
||||
res.results[0] = -b / a;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* QuadraticSolver methods *
|
||||
*************************************************************************/
|
||||
|
||||
@@ -24,6 +24,13 @@ class Solver
|
||||
double a, b, c, d, e;
|
||||
};
|
||||
|
||||
class LinearSolver : public Solver
|
||||
{
|
||||
public:
|
||||
LinearSolver(double a, double b);
|
||||
Result solve();
|
||||
};
|
||||
|
||||
class QuadraticSolver : public Solver
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in new issue
Block a user