Advertisement
rotti321

Complex C++

Aug 17th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef complex<double> cd;
  5.  
  6. cd p;
  7.  
  8. /* x -> real(p) */
  9. /* y -> imag(p) */
  10.  
  11. cd rotire(cd x, double unghi){
  12.     return x * exp(cd(0, unghi)); }
  13.    
  14. cd translatie(cd x, cd delta){
  15.     return x + delta; }
  16.  
  17. cd reflectie(cd x, cd a, cd b){
  18.     // reflectia lui x fata de dreapta ab
  19.     b -= a;
  20.     x -= a;
  21.  
  22.     x /= b;
  23.     x = conj(x);
  24.     x *= b;
  25.  
  26.     b += a;
  27.     x += a;
  28.     return x; }
  29.  
  30. cd reflectie__(cd x, cd a, cd b){
  31.     // reflectia lui x fata de dreapta ab
  32.     return conj((x-a) / (b-a)) * (b-a) + a; }
  33.    
  34. double orient(cd a, cd b, cd c){
  35.     return imag(conj(a-b) * (c-b)); }
  36.  
  37. double len(cd a, cd b){
  38.     return abs(b-a); }
  39.  
  40. double unghi(cd a, cd b){
  41.     return arg(b-a); }
  42.    
  43. int main(){
  44.     cout << "Hello world!" << endl;
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement