Romain Ame / Mbed 2 deprecated Robot2016_2-0_STATIC

Dependencies:   RoboClaw StepperMotor mbed

Fork of Robot2016_2-0 by ARES

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers figure.h Source File

figure.h

00001 #ifndef FIGURE_H
00002 #define FIGURE_H
00003 
00004 #include "point.h"
00005 
00006 class figure {
00007 public:
00008     figure(float xc, float yc) {
00009         xcentre = xc;
00010         ycentre = yc;
00011     }
00012 
00013     float getX () { return xcentre; }
00014     float getY () { return ycentre; }
00015 
00016     bool CroisementSegment (point A1, point A2, point B1, point B2) {
00017         if (ProdVect (A1, A2, B1, B2) != 0) { // On verifie que les droites ne sont pas parallèles
00018             if (ProdVect (A1, A2, A1, B2)*ProdVect (A1, A2, A1, B1) <= 0
00019                 && ProdVect (B1, B2, B1, A1)*ProdVect (B1, B2, B1, A2) <= 0) {
00020                 return true;
00021             }
00022             else {
00023                 return false;
00024             }
00025         }
00026         else {
00027             return false;
00028         }
00029     }
00030 
00031 protected:
00032     float xcentre, ycentre;
00033 
00034     float ProdVect (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
00035         return ((x2 - x1)*(y4 - y3) - (y2 - y1)*(x4 - x3));
00036     }
00037     float ProdVect (point A1, point A2, point B1, point B2) {
00038         return ProdVect (A1.getX(), A1.getY (), A2.getX (), A2.getY (), B1.getX (), B1.getY (), B2.getX (), B2.getY ());
00039     }
00040 };
00041 #endif