git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@283 92aac97c-a6ce-11dd-a772-7fcde58d38e6

This commit is contained in:
chappuis.daniel 2010-02-23 08:37:32 +00:00
parent e05ff5627c
commit 6e87a16e00
2 changed files with 23 additions and 0 deletions

View File

@ -79,6 +79,27 @@ Matrix::Matrix(const Matrix& matrix)
}
}
// Conversion from Matrix3x3
Matrix::Matrix(const Matrix3x3& matrix)
:nbRow(3), nbColumn(3) {
// Create the two dimensional dynamic array
array = new double*[nbRow];
assert(array != 0); // Array pointer musn't be null
for(int i=0; i<nbRow; ++i) {
array[i] = new double[nbColumn];
}
// Copy the matrix
for (int i=0; i<nbRow; ++i) {
for(int j=0; j<nbColumn; ++j) {
setValue(i,j, matrix.getValue(i,j));
}
}
}
// Destructor of the class Matrix
Matrix::~Matrix() {
// Destruction of the dynamic array

View File

@ -22,6 +22,7 @@
// Libraries
#include "exceptions.h"
#include "Matrix3x3.h"
#include <stdexcept>
#include <iostream>
@ -45,6 +46,7 @@ class Matrix {
Matrix(); // Constructor without argument
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
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