The link you posted is broken. Did you mean this?
http://www.acsl.org/acsl/sample_ques/c_4_conic_jr.pdf
To be a circle or elipse, B must be zero, so you should check that too.
I'd pick away at what you know you need. For example, let's start by creating structs that represent a circle and an ellipse in standard form:
struct Circle {
double u, v, r; // (x-u)
2 + (y-v)
2 = r
2
};
struct Ellipse {
double u, v, r1, r2; // (x-u)
2/r1
2 + (y-v)
2/r2
2 = 1
};
Now we just have to set each of these members.
Also, I see that when completing the square for a circle, they assume that the coefficients for x
2 and y
2 are 1. So I ask myself
but what if they aren't 1? Then I notice that for a circle, those coefficients (A & C) must be equal. So you can divide the whole equation by A and that makes A and C 1. Now it's just a question of plowing through the math:
1 2 3 4 5 6 7 8 9 10 11 12
|
if ( coef[i].A == coef[i].C )
{
Circle c;
// do the math to set the u, v, and r members of c
eqnType = "Circle";
}
else
{
Ellipse e;
// do the math to set the u, v, r1, and r2 members of e
eqnType = "Ellipse";
}
|
Hope this helps.