| VF_centerOfGravityV | VD_centerOfGravityV | VE_centerOfGravityV |
|
| Function | Center of Gravity of an array over an explicitly given abscissa |
|
| Syntax C/C++ | #include <VFstd.h>
float VF_centerOfGravityV( fVector X, fVector Y, ui size ); |
| C++ VecObj | #include <OptiVec.h>
T vector<T>::centerOfGravityV( const vector<T>& X ); |
| Pascal/Delphi | uses VFstd;
function VF_centerOfGravityV( X, Y:fVector; size:UIntSize ): Single; |
|
| Description | The center of gravity of the vector Y = f(X) is calculated according to the formula:
COG = sum( Yi * Xi ) / sum( Yi ).
It is assumed that the values of Y represent point masses, situated at the positions given by X. If all elements of X are 0, there is no mass and no gravity; nevertheless, the center of gravity is assumed as the mid-point of X, i.e. (X[size-1] - X[0]) / 2.
To calculate the center of gravity of a vector over its indices as the abscissa, call VF_centerOfGravityInd. |
|
|
| Return value | The (interpolated) position of the center of gravity on the X axis is returned. |
|
|