- 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(textBoxAngle.Text) && !"".Equals(textBoxHeightResult.Text))
- {
- // 底辺
- textBoxBaseResult.Text = "" + calcBase(double.Parse(textBoxHeightResult.Text), double.Parse(textBoxAngle.Text));
-
- // 斜辺
- textBoxHypotenuse.Text = "" + calcHypotenuse(double.Parse(textBoxHeightResult.Text), double.Parse(textBoxAngle.Text));
- }
- }
-
- /**
- * 高さと角度から底辺を求める
- * @height 高さ
- * @angle 角度
- * @return 底辺
- */
- private double calcBase(double height, double angle)
- {
- return height / Math.Tan(Math.PI * angle / 180);
- }
-
- /**
- * 高さと角度から斜辺を求める
- * @height 高さ
- * @angle 角度
- * @return 底辺
- */
- private double calcHypotenuse(double height, double angle)
- {
- return height / Math.Sin(Math.PI * angle / 180);
- }
- }
- }
|