Running average

Hey I was told to find a running average using this code to find the radius of a circle. any idea on how to do a running average?:

void DrawStuff() {
COLORREF green = RGB(0, 255, 0); // green color to draw with
COLORREF purple = RGB(255, 0, 255); // purple color to draw with

char str[32]; // string to store user input
int numPoints; // user input
int *xPts, *yPts; // ptrs for dynamic array of x,y coordinates
int i; // loop and point variables
RECT rect; // rectangle for the output window
int xMin, wdRect, yMin, htRect; // min rectangle coords and rect width & height
//equation for circle = (x - h)^2 + (y - k)^2 = r^2

// clear the scene and add an axis
PGraphics->ClearScene(RGB(0, 0, 0));
PGraphics->AddAxis(RGB(150, 150, 150), 10);

// get the rectangle info for this window
GetClientRect(HOutput, &rect);
wdRect = rect.right - rect.left;
xMin = -wdRect / 2;
htRect = rect.bottom - rect.top;
yMin = -htRect / 2;

// get the user input from the edit boxes and
// convert string input to integer
GetDlgItemText(HDialog, IDC_EDIT_NUMPOINTS, str, 32);
numPoints = atoi(str);

// allocate and initialize the arrays with random point values
xPts = new int[numPoints];
yPts = new int[numPoints];
for (i = 0; i < numPoints; i++) {
// keep points within range -wd/4..+wd/4, -ht/4..+ht/4 so
// bounding circle won't get too large
xPts[i] = wdRect/4 - rand() % (wdRect/2);
yPts[i] = htRect/4 - rand() % (htRect/2);
Circle(xPts[i], yPts[i], 1, green);
}
Topic archived. No new replies allowed.