2015-12-10 19:48:50 +01:00
|
|
|
#include <iostream>
|
2016-01-19 18:27:17 +01:00
|
|
|
#include "vectors.hpp"
|
|
|
|
|
|
|
|
/** A print function the Vector type
|
|
|
|
*
|
|
|
|
* this function print a vector which contains integers
|
|
|
|
*
|
|
|
|
* @tparam NDim dimension of the Vector
|
|
|
|
* @param v the vector to be printed
|
|
|
|
*/
|
|
|
|
template<
|
|
|
|
unsigned int NDim
|
|
|
|
>
|
|
|
|
void printVector(const Vector<NDim, int> v) {
|
|
|
|
printf("Vector [ %d", v[0]);
|
|
|
|
for(int i = 1; i < NDim; i++) {
|
|
|
|
printf(", %d", v[i]);
|
2015-12-10 19:48:50 +01:00
|
|
|
}
|
2016-01-19 18:27:17 +01:00
|
|
|
printf(" ] length %d\n", v.length());
|
|
|
|
}
|
2015-12-10 19:48:50 +01:00
|
|
|
|
2016-01-19 18:27:17 +01:00
|
|
|
/** A print function the Vector type
|
|
|
|
*
|
|
|
|
* this function print a vector which contains floats
|
|
|
|
*
|
|
|
|
* @tparam NDim dimension of the Vector
|
|
|
|
* @param v the vector to be printed
|
|
|
|
*/
|
|
|
|
template<
|
|
|
|
unsigned int NDim
|
|
|
|
>
|
|
|
|
void printVector(const Vector<NDim, float> v) {
|
|
|
|
printf("Vector [ %.3f", v[0]);
|
2015-12-10 19:48:50 +01:00
|
|
|
for(int i = 1; i < NDim; i++) {
|
2016-01-19 18:27:17 +01:00
|
|
|
printf(", %.3f", v[i]);
|
2015-12-10 19:48:50 +01:00
|
|
|
}
|
2016-01-19 18:27:17 +01:00
|
|
|
printf(" ] length %.3f\n", v.length());
|
2015-12-10 19:48:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DIM 3
|
|
|
|
|
|
|
|
int main( int argc, char *argv[] ) {
|
2016-01-19 18:27:17 +01:00
|
|
|
Vector<3,int> a{1,2,3};
|
|
|
|
Vector<3,float> c;
|
2015-12-10 19:48:50 +01:00
|
|
|
|
2016-01-19 18:27:17 +01:00
|
|
|
c = a.normalize();
|
2015-12-10 19:48:50 +01:00
|
|
|
printVector(c);
|
|
|
|
|
2016-01-19 18:27:17 +01:00
|
|
|
a = c;
|
|
|
|
printVector(a);
|
2015-12-10 19:48:50 +01:00
|
|
|
}
|