-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpoint.cpp
More file actions
43 lines (32 loc) · 838 Bytes
/
point.cpp
File metadata and controls
43 lines (32 loc) · 838 Bytes
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
#include <cmath>
#include <cstdio>
#include "element.h"
using namespace std;
point::point():complex(0.0){}
point::point(double _x, double _y):complex(_x, _y){}
point::point(complex c):complex(c){}
point point::mobius(complex c){
return point(((*this) - c)/(1.0 - (*this)*c.conj()));
}
point point::rotate(double theta){
return point((*this)*unit(theta));
}
void point::print(){
printf("Point: ");
complex::print();
}
ideal::ideal(complex c){
if (c.abs2() < 1e-6)
throw "Error getting an ideal point by origin.\n";
*((complex *)this) = c.normal();
}
ideal ideal::mobius(complex c){
return ideal( ((*this) - c) / (1.0 - (*this)*c.conj()) );
}
ideal ideal::rotate(double theta){
return ideal((*this)*unit(theta));
}
void ideal::print(){
printf("Ideal Point: ");
complex::print();
}