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