In the future, humans are exploring space and discover a planet with a long dead civilization. This civilization was fairly advanced and developed a technology that allowed telepathy (the ability to...

1 answer below »
In the future, humans are exploring space and discover a planet with a long dead civilization. This civilization was fairly advanced and developed a technology that allowed telepathy (the ability to share thoughts between any group of individuals without taking.) This technology utilized broadcast towers that work in sets of exactly three towers, each such set forming a triangle. Everyone within the triangle experience telepathy with everyone else within the triangle. Of course, the larger the triangle, the more individuals that could experience telepathy with each other. Upon discovering these towers, humans had a simple question - what is the largest triangle formed by these towers? Your task is to read in the locations of the towers as (x,y) coordinates and report the three towers that give the largest triangle (in terms of area.) There’s a catch though - the largest triangle cannot contain another tower within that triangle or on an edge of the triangle; it turns out that such causes the telepathic system within the larger triangle to fail. For example, consider he following layout of towers and largest resulting valid triangle:In this case, the triangle made by towers BEF is the largest triangle that does not contain any other towers, so would be the answer to the problem. Interestingly, the triangle AEF is larger but contains the tower labelled D - and thus is not a valid triangle. You may find it useful to know that a formula for calculating the area of a triangle with vertices (x1, y1), (x2, y2), (x3, y3) is:area=|(y3−y1)*(x2−x1)−(y2−y1)*(x3−x1)2|You are to write a C++ program (yes, it must be a C++ program!) program that:1.Prompts the user to enter the name of an input file. The first line of the corresponding input file will be a positive integer (of value at least 3 but no more than 26) representing the number of points in the input file. There will then be one additional line for each point in the input file, with each line starting with an uppercase single letter followed by an integer x location and an integer y location that identify a tower. For example, the contents of an input corresponding to the picture above would be:6A 1 0B 4 0C 0 3D 1 3E 4 4F 0 6It is worth noting that you are guaranteed that points will start being identified with ‘A’ and will continue through the alphabet, one letter after the next. I decided to leave them in the input file for clarity’s sake. 2.Prints out the letters identifying the triangle with the largest area that does not contain any other towers. These letters should be in alphabetical order.So, if the above data was stored in an input file called test1.txt, an example run of the program might look like (with program output indicated by regular text and program input in italics):Please enter the name of the input file: test1.txtThe largest telepath
Answered Same DaySep 10, 2021

Answer To: In the future, humans are exploring space and discover a planet with a long dead civilization. This...

Vaibhav answered on Sep 11 2021
171 Votes
program.cpp
program.cpp
//  It is not in the stars to hold our destiny, but in ourselves.
#include 
// ifstre
am for reading the file.
#include 
using namespace std;
// preprocessor directives and typedefs
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define F first
#define S second
#define MP make_pair
#define endl cout << endl
typedef pair> pcii;
// calcuation of area of the triangle as stated.
float area(pcii point, pcii a, pcii b) {
  return abs(((b.S.S - point.S.S) * (a.S.F - point.S.F)) -
             ((a.S.S - point.S.S) * (b.S.F - a.S.F))) /
         2;
}
// determining the direction where the point lies for each pair of coordinates
// of the triangle.
float dir(pcii point, pcii a, pcii b) {
  return (point.S.F - b.S.F) * (a.S.S - b.S.S) -
         (a.S.F - b.S.F) * (point.S.S - b.S.S);
}
// Returns true, if point lies inside, else returns false.
bool isWithin(pcii point, pcii a, pcii b, pcii c) {
  bool neg, pos;
  float s1, s2, s3;
  s1 = dir(point, a, b);
  s2 = dir(point, b, c);
  s3 = dir(point, c, a);
  neg = (s1 < 0) || (s2 < 0) || (s3 < 0);
  pos = (s1 > 0) || (s2 > 0) || (s3 > 0);
  return !(neg && pos);
}
// main
int main() {
  // Th...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here