Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TestMyPathFind by
map/figure.h
- Committer:
- IceTeam
- Date:
- 2016-04-13
- Revision:
- 41:53d5990ff99d
- Parent:
- 39:ca4dd3faffa8
File content as of revision 41:53d5990ff99d:
#ifndef FIGURE_H
#define FIGURE_H
#include "point.h"
class figure {
public:
figure(float xc, float yc) {
xcentre = xc;
ycentre = yc;
}
float getX () { return xcentre; }
float getY () { return ycentre; }
bool CroisementSegment (point A1, point A2, point B1, point B2) {
if (ProdVect (A1, A2, B1, B2) != 0) { // On verifie que les droites ne sont pas parallèles
if (ProdVect (A1, A2, A1, B2)*ProdVect (A1, A2, A1, B1) <= 0
&& ProdVect (B1, B2, B1, A1)*ProdVect (B1, B2, B1, A2) <= 0) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
protected:
float xcentre, ycentre;
float ProdVect (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
return ((x2 - x1)*(y4 - y3) - (y2 - y1)*(x4 - x3));
}
float ProdVect (point A1, point A2, point B1, point B2) {
return ProdVect (A1.getX(), A1.getY (), A2.getX (), A2.getY (), B1.getX (), B1.getY (), B2.getX (), B2.getY ());
}
};
#endif
