VF_centerOfGravityVVD_centerOfGravityVVE_centerOfGravityV
FunctionCenter 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/Delphiuses VFstd;
function VF_centerOfGravityV( X, Y:fVector; size:UIntSize ): Single;
DescriptionThe 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.
Error handlingnone
Return valueThe (interpolated) position of the center of gravity on the X axis is returned.
See alsoVF_centerOfGravityInd

VectorLib Table of Contents  OptiVec home