Is this mathematic operation at all?
@ -121,6 +121,12 @@ void VectorTest::normalized() {
QVERIFY(Vector4(vec).normalized() == Vector4(normalized));
}
void VectorTest::product() {
float vec[] = { 1.0f, 2.0f, 3.0f };
QCOMPARE(Vector3(vec).product(), 6.0f);
void VectorTest::angle() {
float a[] = { 2.0f, 3.0f, 4.0f };
float b[] = { 1.0f, -2.0f, 3.0f };
@ -32,6 +32,7 @@ class VectorTest: public QObject {
void addSubstract();
void length();
void normalized();
void product();
void angle();
void negative();
@ -172,6 +172,16 @@ template<class T, size_t size> class Vector {
return *this/length();
/** @brief Product of values in the vector */
T product() const {
T out = 1;
for(size_t i = 0; i != size; ++i)
out *= at(i);
return out;
private:
T _data[size];
};