- 68
- 0
- 约4.33千字
- 约 3页
- 2017-06-07 发布于重庆
- 举报
C语言源码角度度到弧度转换
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
double x1, x2, y1, y2, dx, dy, s, a;
string m1, m2, m3, m4;
const double PI=3.1415926;
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == )
{
MessageBox.Show(this, 对不起,请输入X1, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (textBox2.Text == )
{
MessageBox.Show(this, 对不起,请输入Y1, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (textBox3.Text == )
{
MessageBox.Show(this, 对不起,请输入X2, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (textBox4.Text == )
{
MessageBox.Show(this, 对不起,请输入Y2, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
x1 = Convert.ToDouble(textBox1.Text);
y1 = Convert.ToDouble(textBox2.Text);
x2 = Convert.ToDouble(textBox3.Text);
y2 = Convert.ToDouble(textBox4.Text);
dx = x2 - x1;
dy = y2 - y1;
s = Math.Sqrt(dx * dx + dy * dy);
a = Math.Atan(dy / dx);
if (dx 0 dy 0)
a = a + PI*2;
if (dx 0 dy 0)
a = a + PI;
if (dx 0 dy 0)
a = a + PI;
m1 = dx.ToString(0.0000);
m2 = dy.ToString(0.0000);
m3 = s.ToString(
原创力文档

文档评论(0)