From f9ea27a46ad9f0c68f9d49aadac5ad44bb6401a6 Mon Sep 17 00:00:00 2001 From: maakshishov Date: Thu, 17 Sep 2020 19:17:03 +0300 Subject: [PATCH] another part of docs for PIMathVector --- libs/main/math/pimathvector.h | 95 +++++++++++++++++++++++++++++++++-- tests/CMakeLists.txt | 1 - 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/libs/main/math/pimathvector.h b/libs/main/math/pimathvector.h index 09659fb2..49b60540 100644 --- a/libs/main/math/pimathvector.h +++ b/libs/main/math/pimathvector.h @@ -1,4 +1,4 @@ -/*! \file pimathvector.h + /*! \file pimathvector.h * \brief PIMathVector * * This file declare math vector class, which performs various vector operations @@ -54,7 +54,7 @@ public: /** * @brief Constructor that fills a vector "PIMathVectorT" with the values ​​of another vector "PIVector" * - * @tparam val vector of type PIVector which is identified PIMathVectorT + * @param val vector of type PIVector which is identified PIMathVectorT * @return vector of type PIMathVectorT with values ​​of vector val */ PIMathVectorT(const PIVector & val) {resize(); PIMV_FOR(i, 0) c[i] = val[i];} @@ -62,8 +62,7 @@ public: /** * @brief Constructor that fills a vector "PIMathVectorT" with the subtraction of two vectors * - * @tparam st vector of type _CVector - * @tparam fn vector of type _CVector + * @param st vector of type PIMathVect * @param fn vector of type PIMathVectorT * @return vector of type PIMathVectorT with values subtraction vectors "fn" and "st" */ PIMathVectorT(const _CVector & st, const _CVector & fn) {resize(); set(st, fn);} @@ -74,18 +73,106 @@ public: * @return type uint shows number of elements in this vector */ uint size() const {return Size;} + + /** + * @brief Method that fills a vector with a value + * + * @param v value of which the vector is filled + * @return vector of type PIMathVector filled with "v" + */ _CVector & fill(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;} + + /** + * @brief Method that fills a vector with the subtraction of two vectors + * + * @param st vector of type PIMathVectorT + * @param fn vector of type PIMathVectorT + * @return vector of type PIMathVectorT with values subtraction vectors "fn" and "st" + */ _CVector & set(const _CVector & st, const _CVector & fn) {PIMV_FOR(i, 0) c[i] = fn[i] - st[i]; return *this;} + + /** + * @brief Method that fills a vector with the adittion of vector value and "v" + * + * @param v value of which the vector is filled + * @return vector of type PIMathVectorT with values adittion of vector value and "v" + */ _CVector & move(const Type & v) {PIMV_FOR(i, 0) c[i] += v; return *this;} + + /** + * @brief Method that fills a vector with the adittion of vector value and "v" + * + * @param v vector of type PIMathVectorT + * @return vector of type PIMathVectorT with values adittion of vector value and "v" + */ _CVector & move(const _CVector & v) {PIMV_FOR(i, 0) c[i] += v[i]; return *this;} + + /** + * @brief Method that returns sum of the squares of all elements of the vector + * + * @return value equal to the sum of the squares of all elements of the vector + */ Type lengthSqr() const {Type tv(0); PIMV_FOR(i, 0) tv += (c[i] * c[i]); return tv;} + + /** + * @brief Method that returns length of a vector + * + * @return value equal to length of a vector + */ Type length() const {return sqrt(lengthSqr());} + + /** + * @brief Method that returns the sum of the absolute values ​​of all vector values + * + * @return value equal sum of the absolute values ​​of all vector values + */ Type manhattanLength() const {Type tv(0); PIMV_FOR(i, 0) tv += fabs(c[i]); return tv;} + + /** + * @brief method that returns the cos of the current vector and vector "v" + * + * @param v vector of type PIMathVectorT + * @return cos value of the angle between two vectors + */ Type angleCos(const _CVector & v) const {Type tv = v.length() * length(); return (tv == Type(0) ? Type(0) : ((*this) ^ v) / tv);} + + /** + * @brief method that returns the sin of the current vector and vector "v". Works only with vectors which consists of 3 elements + * + * @param v vector of type PIMathVectorT * @return sin value of the angle between two vector + */ Type angleSin(const _CVector & v) const {Type tv = angleCos(v); return sqrt(Type(1) - tv * tv);} + + /** + * @brief method that returns the angle between of the current vector and vector "v" in Rad + * + * @param v vector of type PIMathVectorT + * @return value of the angle between two vectors in Rad + */ Type angleRad(const _CVector & v) const {return acos(angleCos(v));} + + /** + * @brief method that returns the angle between of the current vector and vector "v" in Deg + * + * @param v vector of type PIMathVectorT + * @return value of the angle between two vectors in Deg + */ Type angleDeg(const _CVector & v) const {return toDeg(acos(angleCos(v)));} + + /** + * @brief method that returns the angle elevation between of the current vector and vector "v" in Deg + * + * @param v vector of type PIMathVectorT + * @return value of the angle elevation between two vectors in Deg + */ Type angleElevation(const _CVector & v) const {_CVector z = v - *this; double c = z.angleCos(*this); return 90.0 - acos(c) * rad2deg;} + + /** + * @brief method that returns a vector equal to the projection of the current vector onto the vector "v" + * + * @param v vector of type PIMathVectorT + * @return vector of type PIMathVectorT equal to the projection of the current vector onto the vector "v" + */ _CVector projection(const _CVector & v) {Type tv = v.length(); return (tv == Type(0) ? _CVector() : v * (((*this) ^ v) / tv));} _CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;} _CVector normalized() {_CVector tv(*this); tv.normalize(); return tv;} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 07693426..bebb15da 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -17,4 +17,3 @@ endmacro() # Concurrent tests pip_test(concurrent "") pip_test(math "") -#pip_test(core "")