-
Notifications
You must be signed in to change notification settings - Fork 0
/
PComplexe.hpp
150 lines (101 loc) · 4.09 KB
/
PComplexe.hpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef PCOMPLEXE_HPP
#define PCOMPLEXE_HPP
#include "Pfloat.hpp"
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#define PI 3.141592653589793238462643383279502884197169
using namespace std;
class PComplexe{
private :
Pfloat a, b;
public:
/// @brief create 0 + 0i
PComplexe();
/// @brief create a + bi
/// @param _a real number
/// @param _b imaginary number
PComplexe(Pfloat _a, Pfloat _b);
/// @brief copy a precise complexe number
/// @param c the number to copy
PComplexe(const PComplexe& c);
/// @brief representation of precise complexe number
/// @return a precise complexe number representation " a + bi"
const string toString() const;
/// @brief set the real number
/// @param _a new real number
void setRe(Pfloat _a);
/// @brief set the imaginary number
/// @param _b new imaginary number
void setIm(Pfloat _b);
/// @brief get the real number
/// @return real number
Pfloat getRe() const;
/// @brief get the imaginary number
/// @return imaginary number
Pfloat getIm() const;
PComplexe& operator=(const PComplexe& c);
PComplexe& operator+=(const PComplexe& c);
PComplexe& operator-=(const PComplexe& c);
PComplexe operator+(const PComplexe& c);
PComplexe operator-(const PComplexe& c);
bool operator==(const PComplexe& c) const;
bool operator!=(const PComplexe& c) const;
bool operator<(const PComplexe& c) const;
bool operator>(const PComplexe& c) const;
bool operator<=(const PComplexe& c) const;
bool operator>=(const PComplexe& c) const;
PComplexe &operator+=(Pfloat d_a);
PComplexe operator+(Pfloat d_a);
PComplexe &operator-=(Pfloat d_b);
PComplexe operator-(Pfloat d_b);
PComplexe &operator*=(Pfloat d_c);
PComplexe operator*(Pfloat d_c);
PComplexe &operator/=(Pfloat d_c);
PComplexe operator/(Pfloat d_c);
PComplexe &operator*=(const PComplexe& c);
PComplexe operator*(const PComplexe& c);
PComplexe &operator/=(const PComplexe& c);
PComplexe operator/(const PComplexe& c);
/// @brief calculate the conjuagte number of current precise complexe
/// @return conjugate (a - bi)
PComplexe conjugate() const;
/// @brief calulates the distance between (0 + 0i) and current precise complexe
/// @return module
Pfloat abs() const;
/// @brief calulates the angle between (0 + 0i) and current precise complexe
/// @return angle between 0 and 2*pi
Pfloat arg() const;
/// @brief calulates the distance between precise complexe c and current precise complexe
/// @param c other precise complexe
/// @return distance
Pfloat distance(const PComplexe& c) const;
/// @brief calculates the distance between two precise complexes
/// @param c first precise complexe
/// @param d second precise complexe
/// @return distance between
static Pfloat distance(const PComplexe& c, const PComplexe& d);
/// @brief translate a precise complexe by another
/// @param c translation number
/// @return true if successful
bool translate(const PComplexe& c);
bool translate(Pfloat _a, Pfloat _b);
bool translate(Pfloat _a);
/// @brief zoom in or out from 0 + 0i
/// @param zoom zoom value
/// @return true if successful
bool dilation(Pfloat zoom);
/// @brief rotate around 0 + 0i
/// @param angle rotation angle
/// @return true if successful
bool rotate(Pfloat angle);
/// @brief calculate power of a precise complexe number
/// @param exp exponent
/// @return the precise complexe calculated
PComplexe operator^(Pfloat exp);
/// @brief
/// @return exponential of the precise complexe
PComplexe exp();
};
#endif