i have made a c++ program to read some 2d values (x,y) from a text file . My code is as follows:
#include<iostream>
#include<sstream>
#include<fstream>
using namespace std;
template <typename T>
class Node {
public:
T data;
Node<T>* next;
Node<T>* previous;
Node(T data) {
this->data = data;
this->next = NULL;
this->previous = NULL;
}
};
template <typename T>
class List {
public:
int size;
Node<T>* start;
List() {
start = NULL;
size = 0;
}
Node<T>* insert(T data) {
Node<T>* new_node = new Node<T>(data);
new_node->next = start;
new_node->previous = NULL;
if (start != NULL) {
start->previous = new_node;
}
start = new_node;
size += 1;
return new_node;
}
};
class Point {
public:
double x;
double y;
Node<Point*>* points_node;
Point(double x, double y) {
this->x = x;
this->y = y;
}
};
main()
{
List<Point*>* input_points;
input_points = new List<Point*>();
ifstream ifs("input.txt");
double x,y;
ifs>>x>>y;
while(!ifs.eof())
{
Point* p = new Point(x, y);
input_points->insert(p);
ifs>>x>>y;
}
bool line=check_line(input_points); // boolean function not defined
bool circle=check_circle(input_points); // boolean function not defined
}
is there any way to write a boolean function to determine if all the points lie on a line or on a circle or not?
Input file format is as follows:
5.0 10.0
10.0 10.0
15.0 10.0