Add conversion from Vector to Matrix
git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@314 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
9677d4fbae
commit
eddd501bae
|
@ -101,6 +101,19 @@ Matrix::Matrix(const Matrix3x3& matrix)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Conversion from Vector to Matrix
|
||||
Matrix::Matrix(const Vector& vector) {
|
||||
// Create the two dimensional dynamic array
|
||||
array = new double*[vector.getNbComponent()];
|
||||
assert(array != 0);
|
||||
|
||||
for(int i=0; i<nbRow; ++i) {
|
||||
array[i] = new double[1];
|
||||
array[i][0] = vector.getValue(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Destructor of the class Matrix
|
||||
Matrix::~Matrix() {
|
||||
// Destruction of the dynamic array
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
// Libraries
|
||||
#include "exceptions.h"
|
||||
#include "Matrix3x3.h"
|
||||
#include "Vector.h"
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -47,6 +48,7 @@ class Matrix {
|
|||
Matrix(int nbRow, int nbColum) throw(std::invalid_argument); // Constructor of the class Matrix
|
||||
Matrix(const Matrix& matrix); // Copy constructor of the class Matrix
|
||||
Matrix(const Matrix3x3& matrix); // Conversion from Matrix3x3
|
||||
Matrix(const Vector& vector); // Conversion from Vector to Matrix
|
||||
virtual ~Matrix(); // Destructor of the class Matrix
|
||||
double getValue(int i, int j) const throw(std::invalid_argument); // Return a value in the matrix
|
||||
void setValue(int i, int j, double value) throw(std::invalid_argument); // Set a value in the matrix
|
||||
|
|
|
@ -45,7 +45,7 @@ class Vector {
|
|||
public :
|
||||
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 Vector& vector); // Copy-constructor of the class 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
|
||||
|
|
Loading…
Reference in New Issue
Block a user