PIMathVectorT docs update

This commit is contained in:
2020-09-18 16:41:57 +03:00
parent f9ea27a46a
commit b60c147f9d

View File

@@ -1,4 +1,4 @@
/*! \file pimathvector.h
/*! \file pimathvector.h
* \brief PIMathVector
*
* This file declare math vector class, which performs various vector operations
@@ -129,7 +129,7 @@ public:
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"
* @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
@@ -137,14 +137,14 @@ public:
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
* @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
* @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
@@ -152,7 +152,7 @@ public:
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
* @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
@@ -160,29 +160,89 @@ public:
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
*
* @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"
* @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));}
/**
* @brief Method that returns a normalized vector
*
* @return copy of normalized vector of type PIMathVectorT
*/
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs<Type>(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;}
/**
* @brief Method that returns a normalized vector
*
* @return normalized vector of type PIMathVectorT
*/
_CVector normalized() {_CVector tv(*this); tv.normalize(); return tv;}
/**
* @brief Method that returns a vector equal to vector product of current vector and vector "v". Works only with vectors which consists of 3 elements
*
* @param v vector of type PIMathVectorT
* @return vector equal to vector product of current vector and vector "v" type of PIMathVectorT
*/
_CVector cross(const _CVector & v) {return (*this) * v;}
/**
* @brief Method that returns a value equal to absolute value of dot product of current vector and vector "v"
*
* @param v vector of type PIMathVectorT
* @return value equal to absolute value of dot product of current vector and vector "v"
*/
Type dot(const _CVector & v) const {return (*this) ^ v;}
/**
* @brief Method which checks if every elements of vector are zeros
*
* @return true if vector is null, else false
*/
bool isNull() const {PIMV_FOR(i, 0) if (c[i] != Type(0)) return false; return true;}
/**
* @brief Method which checks if current vector is orthogonal to vector "v"
*
* @param v vector of type PIMathVectorT
* @return true if vectors are orthogonal, else false
*/
bool isOrtho(const _CVector & v) const {return ((*this) ^ v) == Type(0);}
const Type & at(uint index) {return c[index];}
/**
* @brief Read-only access to elements reference by index of the vector element "index"
* If you enter an index out of the border of the vector there will be "undefined behavior"
*
* @param index is a parameter that shows the index number of the vector of the selected element
* @return reference to element of vector by index
*/
const Type & at(uint index) {return c[index];}
/**
* @brief Full access to the element of vector by index. If you enter an index out of the border of the vector there will be "undefined behavior"
*
* @param index is the index of necessary element
* @return element of vector
*/
Type & operator [](uint index) {return c[index];}
/**
* @brief Read-only access to the element of vector by index. If you enter an index out of the border of the vector there will be "undefined behavior"
*
* @param index is the index of necessary element
* @return element of vector
*/
Type operator [](uint index) const {return c[index];}
_CVector & operator =(const _CVector & v) {memcpy(c, v.c, sizeof(Type) * Size); return *this;}
_CVector & operator =(const Type & v) {PIMV_FOR(i, 0) c[i] = v; return *this;}