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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
//This is the header file which contains the constructor
#ifndef HEADER_H
#define HEADER_H
#include <iostream>
#include <cstdlib>
#include <list>
#include <fstream>
using namespace std;
class Vertex
{
protected:
int X;
int Y;
double F;
public:
Vertex(int x_in, int y_in);
void setF(double F_in);
void Importance();
int getX();
int getY();
double getF();
};
#endif
//This is the file which contains the constructors functions (importance was where I would put my maths.
#include "Header.h"
Vertex::Vertex(int x_in, int y_in)
{
X = x_in;
Y = y_in;
}
int Vertex::getX()
{
return X;
}
int Vertex::getY()
{
return Y;
}
double Vertex::getF()
{
return F;
}
void Vertex::setF(double F_in)
{
F = F_in;
}
void Vertex::Importance()
{
}
//Main
#include "Header.h"
int main(void)
{
import();
system("PAUSE");
}
void import()
{
ifstream Input;
Input.open("Swallow.txt");
list<Vertex> Xlist;
while (!Input.eof())
{
int x;
int y;
Input >> x >> y;
Vertex v1( x, y);
Xlist.push_back(v1);
if (Input.eof()) break;
}
Input.close();
cout << "Import finished" << endl;
// This is the method I want to use on each object, xP, yP are the x and y stored in the object
//and xL,yL and xR, yR are the x and y coordinates on the points either side of that object in the list.
double importanceMethod(int xP, int yP, int xL, int yL, int xR, int yR)
{
int PL = pow((xP + xL),2) + pow((yP + yL),2);
int PR = pow((xP + xR),2) + pow((yP + yR),2);
int LR = pow((xL + xR),2) + pow((yL + yR),2);
int F = sqrt(PL) + sqrt(PR) - sqrt(LR);
return F;
}
|