dermai0r

Complex.cpp

Jun 20th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include "Complex.h"
  2. #include <iostream>
  3.  
  4. #define PI 3.14159265
  5. Complex::Complex(double lfReal, double lfImg)
  6. {
  7. _real = lfReal;
  8. _img = lfImg;
  9. }
  10.  
  11. Complex::Complex(const Complex& c)
  12. {
  13. double copyReal = c._real;
  14. double copyImg = c._img;
  15. }
  16.  
  17. void Complex::print()
  18. {
  19. std::cout << _real << "+j" << _img << std::endl;
  20. }
  21.  
  22.  
  23.  
  24. double Complex::getReal()
  25. {
  26. return _real;
  27. }
  28.  
  29. double Complex::getImg()
  30. {
  31. return _img;
  32. }
  33.  
  34. double Complex::getAbsValue()
  35. {
  36. double abs = sqrt(_real * _real + _img * _img);
  37.  
  38. return abs;
  39. }
  40.  
  41. double Complex::getAngle()
  42. {
  43. double angle = 360 / (2 * PI) * atan2(_img, _real);
  44. return angle;
  45. }
  46.  
  47. void Complex::setReal(double lfReal)
  48. {
  49. _real = lfReal;
  50. }
  51.  
  52. void Complex::setImg(double lfImg)
  53. {
  54. _img = lfImg;
  55. }
Add Comment
Please, Sign In to add comment