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.
Dependencies: mbed
Diff: Classes/Vector.cpp
- 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