- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
-
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
-
- public Form1()
- {
- InitializeComponent();
- }
-
- private void button1_Click(object sender, EventArgs e)
- {
- if (!"".Equals(textBoxHypotenuse.Text) && !"".Equals(textBoxAngle.Text))
- {
- // 高さ
- textBoxHeightResult.Text = "" + calcHeight(double.Parse(textBoxHypotenuse.Text), double.Parse(textBoxAngle.Text));
- // 底辺
- textBoxBaseResult.Text = "" + calcBase(double.Parse(textBoxHypotenuse.Text), double.Parse(textBoxAngle.Text));
- }
- }
-
- /**
- * 斜辺と角度から高さを求める
- * @hypotenuse 斜辺
- * @angle 角度
- * @return 高さ
- */
- private double calcHeight(double hypotenuse, double angle)
- {
- return hypotenuse * Math.Sin(Math.PI * angle / 180);
- }
-
- /**
- * 斜辺と角度から底辺を求める
- * @hypotenuse 斜辺
- * @angle 角度
- * @return 底辺
- */
- private double calcBase(double hypotenuse, double angle)
- {
- return hypotenuse * Math.Cos(Math.PI * angle / 180);
- }
- }
- }
|