Add the initWithValue() method
git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@320 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
d37110fc38
commit
06f7b0552d
|
@ -37,7 +37,7 @@ Vector::Vector(int n) throw(std::invalid_argument) {
|
|||
nbComponent = n;
|
||||
tab = new double[nbComponent];
|
||||
|
||||
|
||||
// TODO : Remove this initialization
|
||||
// Fill the array with zero's value
|
||||
for(int i=0; i<nbComponent; ++i) {
|
||||
tab[i] = 0.0;
|
||||
|
|
|
@ -52,6 +52,7 @@ 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
|
||||
int getNbComponent() const; // Get the number of components in the vector
|
||||
void initWithValue(double value); // Init all the elements with a given value
|
||||
double length() const; // Get the length of the vector
|
||||
Vector getUnit() const throw(MathematicsException); // Return the corresponding unit vector
|
||||
double scalarProduct(const Vector& vector) const throw(MathematicsException); // Scalar product of two vectors
|
||||
|
@ -115,6 +116,13 @@ inline double Vector::length() const {
|
|||
return sqrt(sum);
|
||||
}
|
||||
|
||||
// Init all the elements with a given value
|
||||
inline void Vector::initWithValue(double value) {
|
||||
for (uint i=0; i<nbComponent; i++) {
|
||||
tab[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Replace a part of the current vector with another sub-vector.
|
||||
// The argument "rowIndex" is the row index where the subVector starts.
|
||||
inline void Vector::fillInSubVector(uint rowIndex, const Vector& subVector) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user