Page d'accueil Description du projet
/******************************************
 *
 *   Cedric Pradalier   2001
 *   mail : http://cedric.pradalier.free.fr/mail.html 
 *
 *****************************************/
#ifndef VECTOR2_H
#define VECTOR2_H

#include "Object.h"

/* Implémentation des vecteurs 2D */
class Vector2 : public Object {
private:
    // Seuil de négligeabilité : pour ==
    static double epsilon;// = 1.0e-8;

public:
    double x,y;
    // Fonction de validation de la classe
    static void Test();

    
    Vector2() {x = y = 0.0;}
    Vector2(const Vector2 & v) {x = v.x; y = v.y;}
    Vector2(double a,double b) {x = a;y = b;}
    virtual ~Vector2() {}

    double getX() const {return x;}
    double getY() const {return y;}
    
    static void setEpsilon(double eps) {epsilon = eps;}
    static double getEpsilon() {return epsilon;}

    // Opérateur de l'espace vectoriel
    Vector2 operator+(const Vector2 & v) const;
    Vector2 operator-(const Vector2 & v) const;
    Vector2 operator*(const double & d) const;
    Vector2 operator/(const double & d) const;
    
    // Produit scalaire (x,y)*(a,b) = ax+by
    double operator*(const Vector2 & v) const;
    // Déterminant (x,y)*(a,b) = xb - ay
    double operator^(const Vector2 & v) const;

    bool operator==(const Vector2 & v) const;
    bool operator!=(const Vector2 & v) const;

    // Vecteur normal (perpendiculaire)
    Vector2 normal() const {return Vector2(-y,x);}
    // Vecteur unitaire, colinéaire a this
    Vector2 unitaire() const; 
    double norme() const;
    // Rotation : en complexe : (x + iy).rotate(t) = (x+iy)*exp(i*t)
    Vector2 rotate(double theta) const;
    // atan2(y,x)
    double angle() const;
    // Conjugue dans le plan complexe : (x+iy).cons() = (x-iy)
    Vector2 conj() const;

    // Affiche {<x>,<y>}\n 
    virtual void Print() {Print(true);}
    // Affichage : si (newline), passage a la ligne
    void Print(bool newline) const;

};
    



#endif // VECTOR2_H