diff --git a/TriangleApplication/MainWindow.xaml b/TriangleApplication/MainWindow.xaml
index 8bfd983..d3046bc 100644
--- a/TriangleApplication/MainWindow.xaml
+++ b/TriangleApplication/MainWindow.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TriangleApplication"
mc:Ignorable="d"
- Title="Triangle Application" Height="400" Width="460"
+ Title="Triangle Application" Height="400" Width="920"
WindowStartupLocation="CenterScreen"
ResizeMode="CanMinimize"
WindowStyle="None"
@@ -15,19 +15,30 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+ Background="#212121"
+ Grid.ColumnSpan="2">
+
+ Margin="290,5,230,5"/>
@@ -155,7 +166,8 @@
CornerRadius="10"
Margin="15 5 15 15"
BorderThickness="1"
- BorderBrush="#212121">
+ BorderBrush="#212121"
+ Grid.Row="2">
-
+
+
+
+
+
+
+
+
+
-
+
diff --git a/TriangleApplication/MainWindow.xaml.cs b/TriangleApplication/MainWindow.xaml.cs
index 95f63a2..0de8b97 100644
--- a/TriangleApplication/MainWindow.xaml.cs
+++ b/TriangleApplication/MainWindow.xaml.cs
@@ -1,7 +1,9 @@
-using System.Windows;
+using System;
+using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
+using System.Windows.Shapes;
namespace TriangleApplication
{
@@ -44,6 +46,8 @@ private void TxtBoxSide_TextChanged(object sender, TextChangedEventArgs e)
? $"These side lengths produce a valid {triangle.GetTriangleAngleType()} {triangle.GetTriangleSideType()} triangle.\n\n" +
$"The angles for the triangle are:\n{triangle.AngleA}°, {triangle.AngleB}°, {triangle.AngleC}°"
: "A triangle is not possible with the given values.";
+
+ DrawTriangle(triangle);
}
else
{
@@ -57,6 +61,39 @@ private void TxtBoxSide_TextChanged(object sender, TextChangedEventArgs e)
}
}
+ private void DrawTriangle(Triangle triangle)
+ {
+ // canvas limits
+ // top left is 0 0, bottom right is 430 300
+ // Height = "300"
+ // Width = "430"
+ // middle of canvas = 215, 150
+ // upper limits are 215, 150 for scaling
+
+ // we also know the angles so...
+ double x1 = triangle.SideA;
+ double y1 = 0;
+
+ double x2 = 0;
+ double y2 = 0;
+
+ // x = x1 + m(y2 - y1) / n
+ double x3 = x1 + (triangle.SideA * (y1 - y2) / triangle.SideB);
+ double y3 = triangle.SideC;
+ //x = start_x + len * cos(angle);
+ //y = start_y + len * sin(angle);
+ // assume we draw the triangle at x, y = 0
+
+ // need to perform calculations prior to this
+ Point pointA = new Point(x1, y1);
+ Point pointB = new Point(x2, y2);
+ Point pointC = new Point(x3, y3);
+
+ PointCollection points = new PointCollection() { pointA, pointB, pointC};
+
+ PolyTriangle.Points = points;
+ }
+
///
/// Validates all user input. Checks if the text boxes
/// are empty and if they have valid values (integers and floats).
diff --git a/TriangleApplication/Triangle.cs b/TriangleApplication/Triangle.cs
index fc1e1e4..8e1afdc 100644
--- a/TriangleApplication/Triangle.cs
+++ b/TriangleApplication/Triangle.cs
@@ -8,9 +8,12 @@ internal class Triangle
public double SideA { get; set; }
public double SideB { get; set; }
public double SideC { get; set; }
- public double AngleB { get; set; }
public double AngleA { get; set; }
+ public double AngleB { get; set; }
public double AngleC { get; set; }
+ public double RadianA { get; set; }
+ public double RadianB { get; set; }
+ public double RadianC { get; set; }
public Triangle(double a, double b, double c)
{
@@ -53,6 +56,10 @@ public void SetTriangleAngles()
double powB = Math.Pow(SideB, 2);
double powC = Math.Pow(SideC, 2);
+ RadianA = Math.Round(Math.Acos((powA + powB - powC) / (2 * SideA * SideB)), 2);
+ RadianB = Math.Round(Math.Acos((powB + powC - powA) / (2 * SideB * SideC)), 2);
+ RadianC = Math.Round(Math.Acos((powC + powA - powB) / (2 * SideC * SideA)), 2);
+
// calculate the angles and round them to 2 decimal places, converts to degrees
AngleA = Math.Round(Math.Acos((powA + powB - powC) / (2 * SideA * SideB)) * (180 / Math.PI), 2);
AngleB = Math.Round(Math.Acos((powB + powC - powA) / (2 * SideB * SideC)) * (180 / Math.PI), 2);