Skip to content
Snippets Groups Projects
Commit a66b74a5 authored by HAQUIN ELOUAN's avatar HAQUIN ELOUAN :surfer:
Browse files

Fixing issue with Vector3D and code refactoring

parent 2b52f7c1
Branches
No related merge requests found
......@@ -4,6 +4,7 @@
#include <stdlib.h>
#define PI 3.14159f
#define RAD 180.0 / PI;
template <typename T>
class Vector3D : public std::_Container_base
......@@ -48,17 +49,17 @@ public:
//VECTORS THINGS
long int scalar_Between(Vector3D& vec1) { return (vec1.get_X() * this->get_X()) + (vec1.getY() * this->get_Y()); }
long double angle_With(Vector3D& vec1) { double vecAngle1 = cos(this->get_Norme()) * 180.0 / PI; double vecAngle2 = cos(vec1.get_Norme()) * 180.0 / PI; return vecAngle1 - vecAngle2; }
long double angle_With(Vector3D& vec1) { double vecAngle1 = cos(this->get_Norme()) * RAD; double vecAngle2 = cos(vec1.get_Norme()) * RAD; return vecAngle1 - vecAngle2; }
long float getLength() { return sqrt(pow(x, 2) * pow(y, 2) * pow(z, 2)); }
long double get_Norme() { return sqrt((this->get_X() * this->get_X()) + (this->get_Y() * this->get_Y()) + (this->get_Z() * this->get_Z())); }
void normalize() { double length = this->get_Norme(); this->set_X(this->get_X() / length); this->set_Y(this->get_Y() / length); }
void normalize() { double length = this->get_Norme(); this->set_X(this->get_X() / length); this->set_Y(this->get_Y() / length); this->set_Y(this->get_Z() / length); }
//TEST FUNCTIONS
bool isPerpendicular(Vector3D& vec2) { return angle_With(this, vec2) == 90 ? true : false; }
bool isNull() { return this.get_X() == 0 && this.get_Y() == 0 ? true : false; }
bool isParallel(Vector3D& vec2) { return this->get_X() / vec2.get_X() == this->get_Y() / vec2.get_Y() ? true : false; }
bool isNormalised() { return this->get_Norme() == 1 ? true : false; }
bool isOpposed(Vector3D& vec2) { return this->isParallel(vec2) && this->get_X() + vec2.get_X() < this->get_X() && this->get_Y() + vec2.get_Y() < this->get_Y() ? true : false; }
bool isPerpendicular(Vector3D& vec2) { return angle_With(this, vec2) == 90; }
bool isNull() { return this.get_X() == 0 && this.get_Y() == 0 && this.get_Z(); }
bool isParallel(Vector3D& vec2) { return this.scalar_Between(v2) / this.getLength() * v2.getLength()) > 1; }
bool isNormalised() { return this->get_Norme() == 1; }
bool isOpposed(Vector3D& vec2) { return this->isParallel(vec2) && this->get_X() + vec2.get_X() < this->get_X() && this->get_Y() + vec2.get_Y() < this->get_Y() && this->get_Z() + vec2.get_Z() < this->get_Z(); }
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment