#include <cstdlib>
#include <iostream>
#include <math.h>

using namespace std;

// Funciones para comprobar si dos vectores2D (en el origen de coord) 
// son iguales.
// El primer vector esta representado en coordenadas cartesianas (v1_x, v1_y)
// mientras que el segundo está en polares (modulo, angulo en grados) ....
float angulo(float v_x, float v_y); 
float modulo(float &v_x, float &v_y);
bool iguales(float v1_x, float v1_y, float v2_mod, float v2_ang);


int main(int argc, char *argv[])
{
    bool res;
    
    res = iguales(1, 1, 1.42, 45);
    cout << "Iguales?: " << res << endl;
    
    system("PAUSE");
    return EXIT_SUCCESS;
}

// Calcula el modulo del vector (v_x, v_y)
float modulo(float &v_x, float &v_y)
{ 
     v_x = v_x*v_x;
     v_y = v_y*v_y; 
     return (sqrt(v_x + v_y));
}

// Calcula el angulo abierto por el vector (v_x, v_y)
float angulo(float v_x, float v_y)
{  
     return (atan(v_y/v_x));
}

// Calcula si dos vectores (v1,v2) son iguales.
// Se permitirá un cierto error...
bool iguales(float v1_x, float v1_y, float v2_mod, float v2_ang)
{
  float v1_mod, v1_ang, error = 0.01;
  
   v1_mod = modulo(v1_x, v1_y); 
   v1_ang = angulo(v1_x, v1_y); 
   if( fabs(v1_mod - v2_mod) > error || 
       fabs(v1_ang - v2_ang) > error)     
       return false;
   else
       return true;
}

