NXPCup_Cachan / Mbed 2 deprecated NXPCup

Dependencies:   mbed

Revision:
0:8743b606abc3
Child:
2:1103f5d61035
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Classes/Vector.cpp	Tue Feb 11 15:41:45 2020 +0000
@@ -0,0 +1,59 @@
+#include "Vector.h"
+#include "math.h"
+
+Vector::Vector(int x0, int y0, int x1, int y1)
+{
+    this->p0.x = x0;
+    this->p0.y = y0;
+    this->p1.x = x1;
+    this->p1.y = y1;
+}
+
+Vector::Vector(Point p0, Point p1)
+{
+    this->p0 = p0;
+    this->p1 = p1;
+}
+
+Vector::Vector()
+{
+}
+
+void Vector::orienteVersLeHaut()
+{
+    if(this->p1.y > this->p0.y)
+    {
+        Point savep0 = this->p0;
+        this->p0 = this->p1;
+        this->p1 = savep0;
+    }
+}
+
+float Vector::getCoeffDir() const
+{
+    return (float)(this->p0.y - this->p1.y) / (float)(this->p1.x - this->p0.x); // y inversés pcq console tsais
+}
+
+int Vector::getNorme() const
+{
+    return sqrt(pow((float)(this->p1.x - this->p0.x), 2) + pow((float)(this->p1.y - this->p0.y), 2));
+}
+
+bool Vector::estADroiteDe(Vector& v) const
+{
+    if(this->p1.x > v.p1.x)
+        return true;
+    return false;
+}
+
+Vector Vector::getVectorAuMilieuDe(Vector& v0, Vector& v1)
+{
+    static Vector vM;
+    
+    vM.p0.x = (v0.p0.x + v1.p0.x) / 2;
+    vM.p0.y = (v0.p0.y + v1.p0.y) / 2;
+    vM.p1.x = (v0.p1.x + v1.p1.x) / 2;
+    vM.p1.y = (v0.p1.y + v1.p1.y) / 2;
+    
+    return vM;
+}
\ No newline at end of file