我想製作一個可以測量窗體上兩個用戶定義點之間角度的工具。目前我沒有任何代碼可以做到這一點,所以任何代碼將不勝感激。C中的角度測量器#
由於
UPDATE
它需要在度和我的點是3個pictureboxes,每個上的每個的三個點的角度的不同的顏色進行測量。
UPDATE
這是我的新的當前代碼:
namespace Angle_Measurer_Tool
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int Dotter = 0;
private void button1_Click(object sender, EventArgs e)
{
Dotter = 1;
}
public int Distance2D(int x1, int y1, int x2, int y2)
{
int result = 0;
double part1 = Math.Pow((x2 - x1), 2);
double part2 = Math.Pow((y2 - y1), 2);
double underRadical = part1 + part2;
result = (int)Math.Sqrt(underRadical);
return result;
}
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
if (Dotter == 1)
{
dot1.Visible = true;
dot1.Location = e.Location;
Dotter = 2;
}
else if (Dotter == 2)
{
dot2.Visible = true;
dot2.Location = e.Location;
Dotter = 3;
}
else if (Dotter == 3)
{
dot3.Visible = true;
dot3.Location = e.Location;
Dotter = 4;
}
else if (Dotter == 4)
{
dot1.Visible = false;
dot2.Visible = false;
dot3.Visible = false;
Dotter = 1;
}
anglesize.Text = Convert
.ToInt32(Distance2D(
dot1.Location,
dot2.Location,
dot3.Location))
.ToString();
}
}
}
,我的問題是實際上是把角的大小,我已經叫anglesize標籤行。
在什麼單位?度?弧度?另外你想如何測量兩個點之間的角度?!還必須有第三個! :D或兩行之間......? – M2X 2010-11-11 21:03:22
你的「現貨」是什麼?這是一個點嗎?它是如何定義的? – 2010-11-11 21:03:23
要添加M2X和Albin Sunnanbo所說的內容,您使用的座標系是什麼?你是用原始像素來做這個,還是使用其他一些度量單位?你對三角學有基本的瞭解嗎? – 2010-11-11 21:04:17