- using System;
- using System.Drawing;
- using System.Windows.Forms;
-
-
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
-
- public Form1()
- {
- InitializeComponent();
- }
-
- private void button1_Click(object sender, EventArgs e)
- {
- if (!"".Equals(textBoxBaseResult.Text) && !"".Equals(textBoxHeightResult.Text))
- {
- // 角度
- textBoxAngle.Text = "" + calcAngle(double.Parse(textBoxBaseResult.Text), double.Parse(textBoxHeightResult.Text));
- // 斜辺
- textBoxHypotenuse.Text = "" + calcHypotenuse(double.Parse(textBoxBaseResult.Text), double.Parse(textBoxHeightResult.Text));
- }
- }
-
- /**
- * 底辺と高さから角度を求める
- * @_base 底辺
- * @height 高さ
- * @return 角度
- */
- private double calcAngle(double _base, double height)
- {
- return Math.Atan(height / _base) * 180 / Math.PI;
- }
-
- /**
- * 底辺と高さから斜辺を求める
- * @_base 底辺
- * @height 高さ
- * @return 斜辺
- */
- private double calcHypotenuse(double _base, double height)
- {
- return Math.Sqrt(Math.Pow(_base, 2) + Math.Pow(height, 2));
- }
-
- }
- }
|