-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.h
47 lines (35 loc) · 1.13 KB
/
functions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef struct cluster_t
{
double x = 0;
double y = 0;
double xSum = 0;
double ySum = 0;
double diameter = 0;
int pointsInCluster = 0;
} Cluster;
typedef struct point_t
{
double x = 0;
double y = 0;
double vx = 0;
double vy = 0;
int centerChanged;
int clusterIndex = -1;
} Point;
void checkFile(FILE* f);
Point* getPointsFromFile(const char* inputFile, int* numOfPoints, int* numOfClusters, double* timeInterval, double* deltaTime, int* maxIterations, double* qualityMeasure);
Cluster* initializeClusters(Point* allPoints, int numOfClusters);
double xPosition(Point p, double time);
double yPosition(Point p, double time);
double calculateDiameter(Point* allPoints, int numOfPoints, int clusterIndex);
double calculateQM(Cluster* clusterCenters, int numOfClusters);
void writeResultsToFile(const char* outputFile, double time, int iter, double terminationQuality, Cluster* clusterCenters, int numOfClusters);
void printPoints(Point* p, int numOfPoints);
void createRandomPointsFile(const char* inputFile);