@@ -132,39 +132,39 @@ public:
* @param v vector of type PIMathVectorT
* @param v vector of type PIMathVectorT
* @return cos value of the angle between two vectors
* @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 ) ; }
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
* @param v vector of type PIMathVectorT
* @return sin value of the angle between two vector
* @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 ) ; }
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
* @param v vector of type PIMathVectorT
* @return value of the angle between two vectors in Rad
* @return value of the angle between two vectors in Rad
*/
*/
Type angleRad ( const _CVector & v ) const { return acos ( angleCos ( v ) ) ; }
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
* @param v vector of type PIMathVectorT
* @return value of the angle between two vectors in Deg
* @return value of the angle between two vectors in Deg
*/
*/
Type angleDeg ( const _CVector & v ) const { return toDeg ( acos ( angleCos ( v ) ) ) ; }
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
* @param v vector of type PIMathVectorT
* @return value of the angle elevation between two vectors in Deg
* @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 ; }
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".
@@ -172,17 +172,17 @@ public:
* @param v vector of type PIMathVectorT
* @param v vector of type PIMathVectorT
* @return vector of type PIMathVectorT equal to the projection of the current vector onto the vector "v"
* @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 projection ( const _CVector & v ) { Type tv = v . length ( ) ; return ( tv = = Type ( 0 ) ? _CVector ( ) : v * ( ( ( * this ) ^ v ) / tv ) ) ; }
/**
/**
* @brief Method that returns this normalized vector
* @brief Method that returns this normalized vector (each element of a vector is divided by the absolute value of this vector)
*
*
* @return reference to this
* @return reference to this
*/
*/
_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 ; }
_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
* @brief Method that returns a normalized vector (each element of a vector is divided by the absolute value of this vector)
*
*
* @return normalized vector of type PIMathVectorT
* @return normalized vector of type PIMathVectorT
*/
*/
@@ -212,11 +212,11 @@ public:
bool isNull ( ) const { PIMV_FOR ( i , 0 ) if ( c [ i ] ! = Type ( 0 ) ) return false ; return true ; }
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"
* @brief Method which checks if current vector is orthogonal to vector "v"
*
*
* @param v vector of type PIMathVectorT
* @param v vector of type PIMathVectorT
* @return true if vectors are orthogonal, else fal */
* @return true if vectors are orthogonal, else fal */
bool isOrtho ( const _CVector & v ) const { return ( ( * this ) ^ v ) = = Type ( 0 ) ; }
bool isOrtho ( const _CVector & v ) const { return ( ( * this ) ^ v ) = = Type ( 0 ) ; }
/**
/**
* @brief Read-only access to elements reference by index of the vector element "index"
* @brief Read-only access to elements reference by index of the vector element "index"
@@ -244,15 +244,16 @@ public:
const Type & operator [ ] ( uint index ) const { return c [ index ] ; }
const Type & operator [ ] ( uint index ) const { return c [ index ] ; }
/**
/**
* @brief Vector a ssignment to vector "v" of type PIMathV ectorT
* @brief A ssignment all elements of this vector with all elements of v ector "v"
* If the vectors have different dimensions, it returns this without changing anything
*
*
* @param v vector for the assigment
* @param v vector for the assigment
* @return vector equal to vector "v"
* @return reference to this
*/
*/
_CVector & operator = ( const _CVector & v ) { memcpy ( c , v . c , sizeof ( Type ) * Size ) ; return * this ; }
_CVector & operator = ( const _CVector & v ) { memcpy ( c , v . c , sizeof ( Type ) * Size ) ; return * this ; }
/**
/**
* @brief Assignment operation. All vector values become equal to "v"
* @brief Assignment all elements of this vector with all elements of value "v"
*
*
* @param v value for the assigment
* @param v value for the assigment
* @return reference to this
* @return reference to this
@@ -260,7 +261,7 @@ public:
_CVector & operator = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] = v ; return * this ; }
_CVector & operator = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] = v ; return * this ; }
/**
/**
* @brief Compare with vector "v"
* @brief Compare all elements of this vector with all elements of vector "v"
*
*
* @param v vector for the compare
* @param v vector for the compare
* @return if vectors are equal true, else false
* @return if vectors are equal true, else false
@@ -268,7 +269,7 @@ public:
bool operator = = ( const _CVector & v ) const { PIMV_FOR ( i , 0 ) if ( c [ i ] ! = v [ i ] ) return false ; return true ; }
bool operator = = ( const _CVector & v ) const { PIMV_FOR ( i , 0 ) if ( c [ i ] ! = v [ i ] ) return false ; return true ; }
/**
/**
* @brief Compare with vector "v"
* @brief Compare all elements of this vector with all elements of vector "v"
*
*
* @param v vector for the compare
* @param v vector for the compare
* @return if vectors are not equal true, else false
* @return if vectors are not equal true, else false
@@ -276,46 +277,46 @@ public:
bool operator ! = ( const _CVector & v ) const { return ! ( * this = = v ) ; }
bool operator ! = ( const _CVector & v ) const { return ! ( * this = = v ) ; }
/**
/**
* @brief Vector addition this vector with vector "v"
* @brief Addition all elements of this vector with all elements vector "v"
*
*
* @param v vector for the addition assigment
* @param v vector for the addition assigment
*/
*/
void operator + = ( const _CVector & v ) { PIMV_FOR ( i , 0 ) c [ i ] + = v [ i ] ; }
void operator + = ( const _CVector & v ) { PIMV_FOR ( i , 0 ) c [ i ] + = v [ i ] ; }
/**
/**
* @brief Subtraction assignment this vector with vector "v"
* @brief Subtraction all elements of this vector with all elements vector "v"
*
*
* @param v vector for the subtraction assigment
* @param v vector for the subtraction assigment
*/
*/
void operator - = ( const _CVector & v ) { PIMV_FOR ( i , 0 ) c [ i ] - = v [ i ] ; }
void operator - = ( const _CVector & v ) { PIMV_FOR ( i , 0 ) c [ i ] - = v [ i ] ; }
/**
/**
* @brief Multiplication assignment this vector with value "v"
* @brief Multiplication all elements of this vector with value "v"
*
*
* @param v value for the multiplication assigment
* @param v value for the multiplication assigment
*/
*/
void operator * = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] * = v ; }
void operator * = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] * = v ; }
/**
/**
* @brief Multiplication assignment this vector with vector "v"
* @brief Multiplication all elements of this vector with all elements vector "v"
*
*
* @param v vector for the multiplication assigment
* @param v vector for the multiplication assigment
*/
*/
void operator * = ( const _CVector & v ) { PIMV_FOR ( i , 0 ) c [ i ] * = v [ i ] ; }
void operator * = ( const _CVector & v ) { PIMV_FOR ( i , 0 ) c [ i ] * = v [ i ] ; }
/**
/**
* @brief Division assignment with this vector value "v"
* @brief Division all elements of this vector with value "v"
*
*
* @param v value for the division assigment
* @param v value for the division assigment
*/
*/
void operator / = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] / = v ; }
void operator / = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] / = v ; }
/**
/**
* @brief Division assignment this vector with vector "v"
* @brief Division all elements of this vector with all elements vector "v"
*
*
* @param v vector for the division assigment
* @param v vector for the division assigment
*/
*/
void operator / = ( const _CVector & v ) { PIMV_FOR ( i , 0 ) c [ i ] / = v [ i ] ; }
void operator / = ( const _CVector & v ) { PIMV_FOR ( i , 0 ) c [ i ] / = v [ i ] ; }
/**
/**
* @brief Vector substraction this vector
* @brief Vector substraction this vector
@@ -325,23 +326,23 @@ public:
_CVector operator - ( ) const { _CVector tv ; PIMV_FOR ( i , 0 ) tv [ i ] = - c [ i ] ; return tv ; }
_CVector operator - ( ) const { _CVector tv ; PIMV_FOR ( i , 0 ) tv [ i ] = - c [ i ] ; return tv ; }
/**
/**
* @brief Vector addition this vector with vector "v"
* @brief Addition all elements of this vector with all elements of vector "v"
*
*
* @param v is vector term
* @param v is vector term
* @return the result of vector addition
* @return the result of vector addition
*/
*/
_CVector operator + ( const _CVector & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] + = v [ i ] ; return tv ; }
_CVector operator + ( const _CVector & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] + = v [ i ] ; return tv ; }
/**
/**
* @brief Vector s ubstraction this vector with vector "v"
* @brief S ubstraction all elements of this vector with all elements of vector "v"
*
*
* @param v is vector term
* @param v is vector term
* @return the result of vector substraction
* @return the result of vector substraction
*/
*/
_CVector operator - ( const _CVector & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] - = v [ i ] ; return tv ; }
_CVector operator - ( const _CVector & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] - = v [ i ] ; return tv ; }
/**
/**
* @brief Vector m ultiplication this vector with value "v"
* @brief M ultiplication all elements of this vector with value "v"
*
*
* @param v is value factor
* @param v is value factor
* @return the result of vector multiplication
* @return the result of vector multiplication
@@ -349,7 +350,7 @@ public:
_CVector operator * ( const Type & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] * = v ; return tv ; }
_CVector operator * ( const Type & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] * = v ; return tv ; }
/**
/**
* @brief Vector division this vector with value "v"
* @brief Division all elements of this vector with value "v"
*
*
* @param v is value divider
* @param v is value divider
* @return the result of vector division
* @return the result of vector division
@@ -357,12 +358,12 @@ public:
_CVector operator / ( const Type & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] / = v ; return tv ; }
_CVector operator / ( const Type & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] / = v ; return tv ; }
/**
/**
* @brief Vector division this vector with vector "v"
* @brief Division all elements of this vector with all elements of vector "v"
*
*
* @param v is vector divider
* @param v is vector divider
* @return the result of vector division
* @return the result of vector division
*/
*/
_CVector operator / ( const _CVector & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] / = v [ i ] ; return tv ; }
_CVector operator / ( const _CVector & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] / = v [ i ] ; return tv ; }
/**
/**
* @brief Cross product of two vectors. Works only with vector containing three elements, otherwise returns current vector
* @brief Cross product of two vectors. Works only with vector containing three elements, otherwise returns current vector
@@ -373,20 +374,20 @@ public:
_CVector operator * ( const _CVector & v ) const { if ( Size ! = 3 ) return _CVector ( ) ; _CVector tv ; tv . fill ( Type ( 1 ) ) ; tv [ 0 ] = c [ 1 ] * v [ 2 ] - v [ 1 ] * c [ 2 ] ; tv [ 1 ] = v [ 0 ] * c [ 2 ] - c [ 0 ] * v [ 2 ] ; tv [ 2 ] = c [ 0 ] * v [ 1 ] - v [ 0 ] * c [ 1 ] ; return tv ; }
_CVector operator * ( const _CVector & v ) const { if ( Size ! = 3 ) return _CVector ( ) ; _CVector tv ; tv . fill ( Type ( 1 ) ) ; tv [ 0 ] = c [ 1 ] * v [ 2 ] - v [ 1 ] * c [ 2 ] ; tv [ 1 ] = v [ 0 ] * c [ 2 ] - c [ 0 ] * v [ 2 ] ; tv [ 2 ] = c [ 0 ] * v [ 1 ] - v [ 0 ] * c [ 1 ] ; return tv ; }
/**
/**
* @brief Elementwise assignment of multiplication of two vectors
* @brief Elementwise assignment of multiplication of two vectors
*
*
* @param v is vector for multiplication
* @param v is vector for multiplication
* @return resulting vector
* @return resulting vector
*/
*/
_CVector operator & ( const _CVector & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] * = v [ i ] ; return tv ; }
_CVector operator & ( const _CVector & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] * = v [ i ] ; return tv ; }
/**
/**
* @brief Absolute value of the dot product
* @brief Absolute value of the dot product
*
*
* @param v is vector for dot product
* @param v is vector for dot product
* @return resulting vector
* @return resulting vector
*/
*/
Type operator ^ ( const _CVector & v ) const { Type tv ( 0 ) ; PIMV_FOR ( i , 0 ) tv + = c [ i ] * v [ i ] ; return tv ; }
Type operator ^ ( const _CVector & v ) const { Type tv ( 0 ) ; PIMV_FOR ( i , 0 ) tv + = c [ i ] * v [ i ] ; return tv ; }
PIMathMatrixT < 1 , Size , Type > transposed ( ) const {
PIMathMatrixT < 1 , Size , Type > transposed ( ) const {
PIMathMatrixT < 1 , Size , Type > ret ;
PIMathMatrixT < 1 , Size , Type > ret ;
@@ -418,7 +419,7 @@ private:
} ;
} ;
/**
/**
* @brief Inline operator which returns vector multiplication with value "x"
* @brief Multiplication all vector elements with value "x"
*
*
* @param x value for the multiplication
* @param x value for the multiplication
* @param v vector for the multiplication
* @param v vector for the multiplication
@@ -430,7 +431,7 @@ inline PIMathVectorT<Size, Type> operator *(const Type & x, const PIMathVectorT<
}
}
/**
/**
* @brief Inline operator for o utputting the vector to the console
* @brief O utputting the vector to the console
*
*
* @param s PICout type
* @param s PICout type
* @param the vector type PIMathVectorT that we print to the console
* @param the vector type PIMathVectorT that we print to the console
@@ -440,7 +441,7 @@ template<uint Size, typename Type>
inline PICout operator < < ( PICout s , const PIMathVectorT < Size , Type > & v ) { s < < " { " ; PIMV_FOR ( i , 0 ) { s < < v [ i ] ; if ( i < Size - 1 ) s < < " , " ; } s < < " } " ; return s ; }
inline PICout operator < < ( PICout s , const PIMathVectorT < Size , Type > & v ) { s < < " { " ; PIMV_FOR ( i , 0 ) { s < < v [ i ] ; if ( i < Size - 1 ) s < < " , " ; } s < < " } " ; return s ; }
/**
/**
* @brief Inline operator c hecking if the cross product is zero. Works only with vector containing three elements, otherwise returns current vector
* @brief C hecking if the cross product of two vectors is zero. Works only with vector containing three elements, otherwise returns current vector
*
*
* @param f vector of the first operand
* @param f vector of the first operand
* @param s vector of the second operand
* @param s vector of the second operand
@@ -450,7 +451,7 @@ template<uint Size, typename Type>
inline bool operator | | ( const PIMathVectorT < Size , Type > & f , const PIMathVectorT < Size , Type > & s ) { return ( f * s ) . isNull ( ) ; }
inline bool operator | | ( const PIMathVectorT < Size , Type > & f , const PIMathVectorT < Size , Type > & s ) { return ( f * s ) . isNull ( ) ; }
/**
/**
* @brief Inline function which takes t he square root of each element in the vector
* @brief T he square root of every element in the vector
*
*
* @param v vector of whose elements the square root is taken
* @param v vector of whose elements the square root is taken
* @return resulting vector
* @return resulting vector
@@ -459,7 +460,7 @@ template<uint Size, typename Type>
inline PIMathVectorT < Size , Type > sqrt ( const PIMathVectorT < Size , Type > & v ) { PIMathVectorT < Size , Type > ret ; PIMV_FOR ( i , 0 ) { ret [ i ] = sqrt ( v [ i ] ) ; } return ret ; }
inline PIMathVectorT < Size , Type > sqrt ( const PIMathVectorT < Size , Type > & v ) { PIMathVectorT < Size , Type > ret ; PIMV_FOR ( i , 0 ) { ret [ i ] = sqrt ( v [ i ] ) ; } return ret ; }
/**
/**
* @brief Inline function which s quares each element of the vector
* @brief S quares every element of the vector
*
*
* @param v vector whose elements are squared
* @param v vector whose elements are squared
* @return resulting vector
* @return resulting vector
@@ -468,7 +469,7 @@ template<uint Size, typename Type>
inline PIMathVectorT < Size , Type > sqr ( const PIMathVectorT < Size , Type > & v ) { PIMathVectorT < Size , Type > ret ; PIMV_FOR ( i , 0 ) { ret [ i ] = sqr ( v [ i ] ) ; } return ret ; }
inline PIMathVectorT < Size , Type > sqr ( const PIMathVectorT < Size , Type > & v ) { PIMathVectorT < Size , Type > ret ; PIMV_FOR ( i , 0 ) { ret [ i ] = sqr ( v [ i ] ) ; } return ret ; }
/**
/**
* @brief Inline operator for s erializing a vector into a PIByteArray
* @brief S erializing a vector into a PIByteArray
*
*
* @param s PIByteArray type
* @param s PIByteArray type
* @param v PIMathVectorT type
* @param v PIMathVectorT type
@@ -478,7 +479,7 @@ template<uint Size, typename Type>
inline PIByteArray & operator < < ( PIByteArray & s , const PIMathVectorT < Size , Type > & v ) { for ( uint i = 0 ; i < Size ; + + i ) s < < v [ i ] ; return s ; }
inline PIByteArray & operator < < ( PIByteArray & s , const PIMathVectorT < Size , Type > & v ) { for ( uint i = 0 ; i < Size ; + + i ) s < < v [ i ] ; return s ; }
/**
/**
* @brief Inline operator to d eserialize vector from PIByteArray
* @brief D eserializing vector from PIByteArray
*
*
* @param s PIByteArray type
* @param s PIByteArray type
* @param v PIMathVector type
* @param v PIMathVector type
@@ -488,7 +489,7 @@ template<uint Size, typename Type>
inline PIByteArray & operator > > ( PIByteArray & s , PIMathVectorT < Size , Type > & v ) { for ( uint i = 0 ; i < Size ; + + i ) s > > v [ i ] ; return s ; }
inline PIByteArray & operator > > ( PIByteArray & s , PIMathVectorT < Size , Type > & v ) { for ( uint i = 0 ; i < Size ; + + i ) s > > v [ i ] ; return s ; }
/**
/**
* @brief Inline f unction which returns vector size 2 and type of T
* @brief F unction which returns vector size 2 and type of T
*
*
* @param x first element of vector
* @param x first element of vector
* @param y second element of vector
* @param y second element of vector
@@ -498,7 +499,7 @@ template<typename T>
inline PIMathVectorT < 2u , T > createVectorT2 ( T x , T y ) { return PIMathVectorT < 2u , T > ( PIVector < T > ( ) < < x < < y ) ; }
inline PIMathVectorT < 2u , T > createVectorT2 ( T x , T y ) { return PIMathVectorT < 2u , T > ( PIVector < T > ( ) < < x < < y ) ; }
/**
/**
* @brief Inline f unction which returns vector size 3 and type of T
* @brief F unction which returns vector size 3 and type of T
*
*
* @param x first element of vector
* @param x first element of vector
* @param y second element of vector
* @param y second element of vector
@@ -509,7 +510,7 @@ template<typename T>
inline PIMathVectorT < 3u , T > createVectorT3 ( T x , T y , T z ) { return PIMathVectorT < 3u , T > ( PIVector < T > ( ) < < x < < y < < z ) ; }
inline PIMathVectorT < 3u , T > createVectorT3 ( T x , T y , T z ) { return PIMathVectorT < 3u , T > ( PIVector < T > ( ) < < x < < y < < z ) ; }
/**
/**
* @brief Inline f unction which returns vector size 4 and type of T
* @brief F unction which returns vector size 4 and type of T
*
*
* @param x first element of vector
* @param x first element of vector
* @param y second element of vector
* @param y second element of vector
@@ -699,14 +700,14 @@ public:
_CVector projection ( const _CVector & v ) { if ( v . size ( ) ! = c . size ( ) ) return * this ; Type tv = v . length ( ) ; return ( tv = = Type ( 0 ) ? _CVector ( ) : v * ( ( ( * this ) ^ v ) / tv ) ) ; }
_CVector projection ( const _CVector & v ) { if ( v . size ( ) ! = c . size ( ) ) return * this ; Type tv = v . length ( ) ; return ( tv = = Type ( 0 ) ? _CVector ( ) : v * ( ( ( * this ) ^ v ) / tv ) ) ; }
/**
/**
* @brief Method that returns a normalized vector
* @brief Method that returns a normalized vector (each element of a vector is divided by the absolute value of this vector)
*
*
* @return copy of normalized vector of type PIMathVector
* @return copy of normalized vector of type PIMathVector
*/
*/
_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 ; }
_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
* @brief Method that returns a normalized vector (each element of a vector is divided by the absolute value of this vector)
*
*
* @return normalized vector of type PIMathVector
* @return normalized vector of type PIMathVector
*/
*/
@@ -720,7 +721,7 @@ public:
bool isNull ( ) const { PIMV_FOR ( i , 0 ) if ( c [ i ] ! = Type ( 0 ) ) return false ; return true ; }
bool isNull ( ) const { PIMV_FOR ( i , 0 ) if ( c [ i ] ! = Type ( 0 ) ) return false ; return true ; }
/**
/**
* @brief Method which checks if vector is valid
* @brief Method which checks if vector is empty
*
*
* @return true if vector is valid, else false
* @return true if vector is valid, else false
*/
*/
@@ -761,7 +762,7 @@ public:
const Type & operator [ ] ( uint index ) const { return c [ index ] ; }
const Type & operator [ ] ( uint index ) const { return c [ index ] ; }
/**
/**
* @brief Vector a ssignment to vector "v" of type PIMathV ector
* @brief A ssignment all elements of this vector with all elements of v ector "v"
* If the vectors have different dimensions, it returns this without changing anything
* If the vectors have different dimensions, it returns this without changing anything
*
*
* @param v vector for the assigment
* @param v vector for the assigment
@@ -770,7 +771,7 @@ public:
_CVector & operator = ( const _CVector & v ) { if ( v . size ( ) ! = c . size ( ) ) return * this ; c = v . c ; return * this ; }
_CVector & operator = ( const _CVector & v ) { if ( v . size ( ) ! = c . size ( ) ) return * this ; c = v . c ; return * this ; }
/**
/**
* @brief Vector assignment to value "v"
* @brief Assignment all elements of this vector with all elements of value "v"
*
*
* @param v value for the assigment
* @param v value for the assigment
* @return reference to this
* @return reference to this
@@ -778,7 +779,7 @@ public:
_CVector & operator = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] = v ; return * this ; }
_CVector & operator = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] = v ; return * this ; }
/**
/**
* @brief Compare with vector "v"
* @brief Compare all elements of this vector with all elements of vector "v"
*
*
* @param v vector for the compare
* @param v vector for the compare
* @return if vectors are equal true, else false
* @return if vectors are equal true, else false
@@ -786,7 +787,7 @@ public:
bool operator = = ( const _CVector & v ) const { PIMV_FOR ( i , 0 ) if ( ( c [ i ] ! = v [ i ] ) | | ( v . size ( ) ! = c . size ( ) ) ) return false ; return true ; }
bool operator = = ( const _CVector & v ) const { PIMV_FOR ( i , 0 ) if ( ( c [ i ] ! = v [ i ] ) | | ( v . size ( ) ! = c . size ( ) ) ) return false ; return true ; }
/**
/**
* @brief Compare with vector "v"
* @brief Compare all elements of this vector with all elements of vector "v"
*
*
* @param v vector for the compare
* @param v vector for the compare
* @return if vectors are not equal true, else false
* @return if vectors are not equal true, else false
@@ -794,42 +795,42 @@ public:
bool operator ! = ( const _CVector & v ) const { return ! ( * this = = v ) ; }
bool operator ! = ( const _CVector & v ) const { return ! ( * this = = v ) ; }
/**
/**
* @brief Addition assignment this vector with vector "v". If the vectors have different dimensions, it returns void()
* @brief Addition all elements of this vector with all elements vector "v". If the vectors have different dimensions, it returns void()
*
*
* @param v vector for the addition assigment
* @param v vector for the addition assigment
*/
*/
void operator + = ( const _CVector & v ) { if ( v . size ( ) ! = c . size ( ) ) return void ( ) ; PIMV_FOR ( i , 0 ) c [ i ] + = v [ i ] ; }
void operator + = ( const _CVector & v ) { if ( v . size ( ) ! = c . size ( ) ) return void ( ) ; PIMV_FOR ( i , 0 ) c [ i ] + = v [ i ] ; }
/**
/**
* @brief Subtraction assignment this vector with vector "v". If the vectors have different dimensions, it returns void()
* @brief Subtraction all elements of this vector with all elements vector "v". If the vectors have different dimensions, it returns void()
*
*
* @param v vector for the subtraction assigment
* @param v vector for the subtraction assigment
*/
*/
void operator - = ( const _CVector & v ) { if ( v . size ( ) ! = c . size ( ) ) return void ( ) ; PIMV_FOR ( i , 0 ) c [ i ] - = v [ i ] ; }
void operator - = ( const _CVector & v ) { if ( v . size ( ) ! = c . size ( ) ) return void ( ) ; PIMV_FOR ( i , 0 ) c [ i ] - = v [ i ] ; }
/**
/**
* @brief Multiplication assignment this vector with value "v"
* @brief Multiplication all elements of this vector with value "v"
*
*
* @param v value for the multiplication assigment
* @param v value for the multiplication assigment
*/
*/
void operator * = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] * = v ; }
void operator * = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] * = v ; }
/**
/**
* @brief Multiplication assignment this vector with vector "v". If the vectors have different dimensions, it returns void()
* @brief Multiplication all elements of this vector with all elements vector "v". If the vectors have different dimensions, it returns void()
*
*
* @param v vector for the multiplication assigment
* @param v vector for the multiplication assigment
*/
*/
void operator * = ( const _CVector & v ) { if ( v . size ( ) ! = c . size ( ) ) return void ( ) ; PIMV_FOR ( i , 0 ) c [ i ] * = v [ i ] ; }
void operator * = ( const _CVector & v ) { if ( v . size ( ) ! = c . size ( ) ) return void ( ) ; PIMV_FOR ( i , 0 ) c [ i ] * = v [ i ] ; }
/**
/**
* @brief Division assignment this vector with value "v"
* @brief Division all elements of this vector with value "v"
*
*
* @param v value for the division assigment
* @param v value for the division assigment
*/
*/
void operator / = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] / = v ; }
void operator / = ( const Type & v ) { PIMV_FOR ( i , 0 ) c [ i ] / = v ; }
/**
/**
* @brief Division assignment this vector with vector "v". If the vectors have different dimensions, it returns void()
* @brief Division all elements of this vector with all elements vector "v". If the vectors have different dimensions, it returns void()
*
*
* @param v vector for the division assigment
* @param v vector for the division assigment
*/
*/
@@ -843,15 +844,15 @@ public:
_CVector operator - ( ) const { _CVector tv ; PIMV_FOR ( i , 0 ) tv [ i ] = - c [ i ] ; return tv ; }
_CVector operator - ( ) const { _CVector tv ; PIMV_FOR ( i , 0 ) tv [ i ] = - c [ i ] ; return tv ; }
/**
/**
* @brief Vector addition this vector with vector "v". If the vectors have different dimensions, it returns this without changing anything
* @brief Addition all elements of this vector with all elements of vector "v". If the vectors have different dimensions, it returns this without changing anything
*
*
* @param v is vector term
* @param v is vector term
* @return the result of matrix addition
* @return the result of vector addition
*/
*/
_CVector operator + ( const _CVector & v ) const { if ( v . size ( ) ! = c . size ( ) ) return _CVector ( * this ) ; _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] + = v [ i ] ; return tv ; }
_CVector operator + ( const _CVector & v ) const { if ( v . size ( ) ! = c . size ( ) ) return _CVector ( * this ) ; _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] + = v [ i ] ; return tv ; }
/**
/**
* @brief Vector s ubstraction this vector with vector "v". If the vectors have different dimensions, it returns this without changing anything
* @brief S ubstraction all elements of this vector with all elements of vector "v". If the vectors have different dimensions, it returns this without changing anything
*
*
* @param v is vector term
* @param v is vector term
* @return the result of vector substraction
* @return the result of vector substraction
@@ -859,7 +860,7 @@ public:
_CVector operator - ( const _CVector & v ) const { if ( v . size ( ) ! = c . size ( ) ) return _CVector ( * this ) ; _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] - = v [ i ] ; return tv ; }
_CVector operator - ( const _CVector & v ) const { if ( v . size ( ) ! = c . size ( ) ) return _CVector ( * this ) ; _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] - = v [ i ] ; return tv ; }
/**
/**
* @brief Vector m ultiplicationthis vector with value "v"
* @brief M ultiplication all elements of this vector with value "v"
*
*
* @param v is value factor
* @param v is value factor
* @return the result of vector multiplication
* @return the result of vector multiplication
@@ -867,7 +868,7 @@ public:
_CVector operator * ( const Type & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] * = v ; return tv ; }
_CVector operator * ( const Type & v ) const { _CVector tv = _CVector ( * this ) ; PIMV_FOR ( i , 0 ) tv [ i ] * = v ; return tv ; }
/**
/**
* @brief Vector division this vector with value "v"
* @brief Division all elements of this vector with value "v"
*
*
* @param v is value divider
* @param v is value divider
* @return the result of vector division
* @return the result of vector division
@@ -932,7 +933,7 @@ inline std::ostream & operator <<(std::ostream & s, const PIMathVector<Type> & v
# endif
# endif
/**
/**
* @brief Inline operator for o utputting the vector to the console
* @brief O utputting the vector to the console
*
*
* @param s PICout type
* @param s PICout type
* @param the vector type PIMathVector that we print to the console
* @param the vector type PIMathVector that we print to the console
@@ -942,7 +943,7 @@ template<typename Type>
inline PICout operator < < ( PICout s , const PIMathVector < Type > & v ) { s < < " Vector{ " ; for ( uint i = 0 ; i < v . size ( ) ; + + i ) { s < < v [ i ] ; if ( i < v . size ( ) - 1 ) s < < " , " ; } s < < " } " ; return s ; }
inline PICout operator < < ( PICout s , const PIMathVector < Type > & v ) { s < < " Vector{ " ; for ( uint i = 0 ; i < v . size ( ) ; + + i ) { s < < v [ i ] ; if ( i < v . size ( ) - 1 ) s < < " , " ; } s < < " } " ; return s ; }
/**
/**
* @brief Inline operator for s erializing a vector into a PIByteArray
* @brief S erializing a vector into a PIByteArray
*
*
* @param s PIByteArray type
* @param s PIByteArray type
* @param v PIMathVector type
* @param v PIMathVector type
@@ -952,7 +953,7 @@ template<typename Type>
inline PIByteArray & operator < < ( PIByteArray & s , const PIMathVector < Type > & v ) { s < < v . c ; return s ; }
inline PIByteArray & operator < < ( PIByteArray & s , const PIMathVector < Type > & v ) { s < < v . c ; return s ; }
/**
/**
* @brief Inline operator to d eserialize vector from PIByteArray
* @brief D eserializing vector from PIByteArray
*
*
* @param s PIByteArray type
* @param s PIByteArray type
* @param v PIMathVector type
* @param v PIMathVector type