In this coursework you are not allowed to change the name of
Solution
#include<iostream>
#include<conio.h>
#include<math.h>
#define PI 3.14159265;
using namespace std;
double Distance(double a1, double b1, double a2, double b2)
{
double a, b, distance;
x = a2 - a1;
y = b2 - b1;
dst = pow(a,2) + pow(b,2);
dst = sqrt(dst);
return dst;
}
double otherAngleFind(double bg_A, double l_d, double s_d)
{
double o_a;
o_a = s_d *sin(b_a*3.14159265/180);
o_a = o_a/l_a;
o_a = asin(o_a)*180.0 / PI;
return o_a;
}
double BiggerAngleFind(double l_d, double s_d, double s_D_2)
{
double b_a;
b_a = pow(s_d,2) + pow(s_d_2, 2) - pow(l_d,2);
b_a = fabs(b_a/(2*s_d*s_d_2));
b_a = acos(b_a)* 180.0 / PI;
return b_a;
}
void TriangleAngleCalculation(double x1, double y1, double x2, double y2, double x3, double y3)
{
double d1, d2, d3;
double g1, g2, g3;
double ttl;
int lL = 0;
d1 = DistanceTwoPoints(a1, b1, a2, b2);
d2 = DistanceTwoPoints(a2, b2, a3, b3);
d3 = DistanceTwoPoints(a1, b1, a3, b3);
cout<<\"Distance\"<<d1<<\" \"<<d2<<\" \"<<d3;
if(d1>d2 && d1 > d3)
{
//cout<<\"distance1 is greater\";
g1 = BiggerAngleFind(d1, d2, d3);
g2 = otherAngleFind(g1, d1, d2);
g3 = otherAngleFind(g1, d1, d3);
//g2 = OtherAngleFind(g1, d1, d2);
ttl=g1+g2+g3;
if(ttl <180)
{
g1 = 180 - g1;
}
}
else if(d2 > d3 && d2 > d1)
{
// cout<<\"distance 2 is greater\";
g2 = BiggerAngleFind(d2, d1, d3);
g1 = otherAngleFind(g2, d2, d1);
g3 = otherAngleFind(g2, d2, d3);
ttl=g1+g2+g3;
if(ttl <180)
{
g2 = 180 -g2;
}
}
else
{
// cout<<\"distance 3 is greater\";
g3 = BiggerAngleFind(d3, d1, d2);
g1 = otherAngleFind(g3, d3, d2);
g2 = otherAngleFind(g3, d3, d2);
ttl=g1+g2+g3;
if(ttl <180)
{
g3 = 180 - g3;
}
}
cout<<endl<<\"Angle Between First Point and Second Point = \"<<g3<<endl;
cout<<\"Angle Between First Point and Third Point = \"<<g2<<endl;
cout<<\"Angle Between Second Point and Third Point = \"<<g1<<endl;
}
int main()
{
double a1, b1, a2, b2, a3, b3;
cout<<\"Enter a cordinate value of first coordinate in the triangle = \";
cin>>a1;
cout<<\"Enter b cordinate value of first coordinate in the triangle = \";
cin>>b1;
cout<<\"Enter a cordinate value of second coordinate in the triangle = \";
cin>>a2;
cout<<\"Enter b cordinate value of second coordinate in the triangle = \";
cin>>b2;
cout<<\"Enter a cordinate value of third coordinate of triangle = \";
cin>>a3;
cout<<\"Enter b cordinate value of third coordinate of triangle = \";
cin>>b3;
cout<<endl<<\" Point1 of a triangle is (\"<<a1<<\" , \"<<b1<<\")\"<<endl;
cout<<\"Point2of a triangle is is (\"<<a2<<\" , \"<<b2<<\")\"<<endl;
cout<<\" Point3 of a triangle is is (\"<<a3<<\" , \"<<b3<<\")\"<<endl;
TriangleAngleCalculation(a1, b1, a2, b2, a3, b3);
getch();
}


