- 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(textBoxHeight.Text) && !"".Equals(textBoxHypotenuse.Text))
- {
- // 角度
- textBoxAngle.Text = "" + calcAngle(double.Parse(textBoxHeight.Text), double.Parse(textBoxHypotenuse.Text));
-
- // 底辺
- textBoxBase.Text = "" + calcBase(double.Parse(textBoxHeight.Text), double.Parse(textBoxHypotenuse.Text));
- }
- }
-
- /**
- * 高さと斜辺から角度を求める
- * @height 高さ
- * @hypotenuse 斜辺
- * @return 角度
- */
- private double calcAngle(double height, double hypotenuse)
- {
- return Math.Asin(height / hypotenuse) * 180 / Math.PI;
- }
-
- /**
- * 高さと斜辺から底辺を求める
- * @height 高さ
- * @hypotenuse 斜辺
- * @return 底辺
- */
- private double calcBase(double height, double hypotenuse)
- {
- return Math.Sqrt(Math.Pow(hypotenuse, 2) - Math.Pow(height, 2));
- }
- }
- }
|