-
Notifications
You must be signed in to change notification settings - Fork 1
/
cp1point.cpp
52 lines (45 loc) · 850 Bytes
/
cp1point.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "cp1point.h"
CP1Point::CP1Point()
{
}
CP1Point::CP1Point(const Complex &z)
{
z1 = z;
z2 = 1.0;
}
CP1Point::CP1Point(const Complex &z1, const Complex &z2) : z1(z1), z2(z2)
{
}
bool CP1Point::isInfinity() const
{
return z2 == 0.0;
}
Complex CP1Point::getComplexCoordinate() const
{
if (!isInfinity())
{
return z1 / z2;
}
else
{
qDebug() << "Warning in CP1Point::getComplexCoordinate(): [1 : 0] is not a complex number";
return Complex(1.0/0.0);
}
}
bool operator==(const CP1Point & p1, const CP1Point & p2)
{
Complex test = p1.z1*p2.z2 - p1.z2*p2.z1;
return test == 0.0;
}
std::ostream & operator<<(std::ostream & out, const CP1Point &p)
{
if (p.z2 == 0.0)
{
out << "infinity";
}
else
{
out << p.z1 / p.z2 ;
}
return out;
}