From 870223ba8774c0ae5136203a4ec843b03270f92f Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Mon, 17 May 2010 21:44:38 +0000 Subject: [PATCH] Add the conversion from Vector3D to Vector git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@317 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- sources/reactphysics3d/mathematics/Vector.cpp | 10 ++++++++++ sources/reactphysics3d/mathematics/Vector.h | 2 ++ 2 files changed, 12 insertions(+) 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