Page d'accueil Description du projet
#ifndef SEGMENT_H
#define SEGMENT_H
/*********************************************
 *
 * Cedric Pradalier
 * DEA 2000/2001 
 * INRIA Rhones Alpes
 * http://cedric.pradalier.free.fr/index.html
 * mail : http://cedric.pradalier.free.fr/mail.html
 *
 * *******************************************/


#include "Object.h"
#include "vector2.h"
#include <stdlib.h>
#include <stdio.h>


class Segment : public Object {

    public :
        Vector2 A,B;

    public :
        Segment() { A = B = Vector2(0,0) ; }
        Segment(const Vector2 & a, const Vector2 & b)
        { A = a; B = b; }
        Segment(const Segment & rhs)
        { A = rhs.A ; B = rhs.B ; }

        virtual ~Segment() {}

        virtual void Print() {
            printf("( A : ");A.Print(false);
            printf("; B : ");B.Print(false);
            printf(")\n");
        }
            

        /* Calcul l'intersection entre la droite passant par
         * origine et dirigee par theta_rad et le segment.
         * La validite de l'intersection est verifiee.
         * Le resultat est le reel l positif tel que 
         *  origine + l * direction 
         * est sur [A,B]. Retourne -1 s'il n'y a pas d'intersection
         * */
        double intersect(const Vector2 & origine, double theta_rad);
        // as above. I = A + mu * (B-A)
        double intersect(const Vector2 & origine, 
                const Vector2 & diri,double * mu);
        Vector2 intersectNoCheck(const Segment & S2);

        Vector2 bary(double lambda){return A*lambda+B*(1-lambda);}

};


#endif // SEGMENT_H