diff --git a/sources/reactphysics3d/mathematics/Vector.cpp b/sources/reactphysics3d/mathematics/Vector.cpp index 4af1a3e6..5561b31c 100644 --- a/sources/reactphysics3d/mathematics/Vector.cpp +++ b/sources/reactphysics3d/mathematics/Vector.cpp @@ -60,6 +60,16 @@ Vector::Vector(const Vector& vector) { } } +// Conversion from Vector3D to Vector +Vector::Vector(const Vector3D& vector3d) { + nbComponent = 3; + tab = new double[3]; + + tab[0] = vector3d.getX(); + tab[1] = vector3d.getY(); + tab[2] = vector3d.getZ(); +} + // Destructor of the class Vector Vector::~Vector() { // Erase the array with the values of the vector diff --git a/sources/reactphysics3d/mathematics/Vector.h b/sources/reactphysics3d/mathematics/Vector.h index 90c9a130..5875e233 100644 --- a/sources/reactphysics3d/mathematics/Vector.h +++ b/sources/reactphysics3d/mathematics/Vector.h @@ -21,6 +21,7 @@ #define VECTOR_H // Libraries +#include "Vector3D.h" #include "../typeDefinitions.h" #include "mathematics_functions.h" #include "exceptions.h" @@ -46,6 +47,7 @@ class Vector { Vector(); // Constructor without argument Vector(int n) throw(std::invalid_argument); // Constructor of the class Vector Vector(const Vector& vector); // Copy-constructor of the class Vector + Vector(const Vector3D& vector3d); // Conversion from Vector3D to Vector virtual ~Vector(); // Destructor of the class Vector double getValue(int n) const throw(std::invalid_argument); // Get a component of the vector void setValue(int n, double value) throw(std::invalid_argument); // Set the value of a component of the vector