資源簡(jiǎn)介
采用C#開發(fā)經(jīng)過三個(gè)點(diǎn)繪制圓弧的測(cè)試程序, 在主界面上用鼠標(biāo)左鍵在不同位置按下三次,將繪制經(jīng)過這三個(gè)點(diǎn)的圓弧

代碼片段和文件信息
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?ArcPointTest
{
????public?partial?class?ArcPointTest?:?Form
????{
????????Point?FirstPoint?=?new?Point();
????????Point?SecondPoint?=?new?Point();
????????Point?ThirdPoint?=?new?Point();
????????int?PointNum;
????????public?ArcPointTest()
????????{
????????????InitializeComponent();
????????????PointNum?=?0;
????????}
????????private?void?MainForm_MouseClick(object?sender?MouseEventArgs?e)
????????{
????????????if?(e.Button?==?System.Windows.Forms.MouseButtons.Left)
????????????{
????????????????Graphics?g?=?this.CreateGraphics();
????????????????SolidBrush?m_Brush?=?new?SolidBrush(Color.Blue);
????????????????g.SmoothingMode?=?System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
????????????????if?(PointNum?==?0)
????????????????{
????????????????????FirstPoint.X?=?e.X;
????????????????????FirstPoint.Y?=?e.Y;
????????????????}
????????????????if?(PointNum?==?1)
????????????????{
????????????????????SecondPoint.X?=?e.X;
????????????????????SecondPoint.Y?=?e.Y;
????????????????}
????????????????if?(PointNum?==?2)
????????????????{
????????????????????ThirdPoint.X?=?e.X;
????????????????????ThirdPoint.Y?=?e.Y;
????????????????}
????????????????g.FillEllipse(m_Brush?e.X?-?3?e.Y?-?3?6?6);
????????????????PointNum++;
????????????????if?(PointNum?==?3)
????????????????{
????????????????????PointNum?=?0;
????????????????????DrawArcFromThreePoint(g?FirstPoint.X?FirstPoint.Y?SecondPoint.X?SecondPoint.Y?ThirdPoint.X?ThirdPoint.Y);
????????????????}
????????????}
????????}
????????/*
?????????*?利用三點(diǎn)坐標(biāo)獲得圓弧
?????????*/?
????????void?DrawArcFromThreePoint(Graphics?mImgGraph?int?x1?int?y1?int?x2?int?y2?int?x3?int?y3)
????????{
????????????double?a?=?x1?-?x2;
????????????double?b?=?y1?-?y2;
????????????double?c?=?x1?-?x3;
????????????double?d?=?y1?-?y3;
????????????double?e?=?((x1?*?x1?-?x2?*?x2)?+?(y1?*?y1?-?y2?*?y2))?/?2.0;
????????????double?f?=?((x1?*?x1?-?x3?*?x3)?+?(y1?*?y1?-?y3?*?y3))?/?2.0;
????????????double?det?=?b?*?c?-?a?*?d;
????????????if?(Math.Abs(det)?>?0.001)
????????????{
????????????????//x0y0為計(jì)算得到的原點(diǎn)
????????????????double?x0?=?-(d?*?e?-?b?*?f)?/?det;
????????????????double?y0?=?-(a?*?f?-?c?*?e)?/?det;
????????????????SolidBrush?OriginBrush?=?new?SolidBrush(Color.Blue);
????????????????mImgGraph.FillEllipse(OriginBrush?(int)(x0?-?3)?(int)(y0?-?3)?6?6);
????????????????double?radius?=?Math.Sqrt((x1?-?x0)?*?(x1?-?x0)?+?(y1?-?y0)?*?(y1?-?y0));
????????????????double?angle1;
????????????????double?angle2;
????????????????double?angle3;
????????????????double?sinValue1;
????????????????double?cosValue1;
????????????????double?sinValue2;
????????????????double?cosValue2;
?????????????
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-03-15?08:01??ArcPointTest\
?????目錄???????????0??2018-03-15?08:01??ArcPointTest\ArcPointTest\
?????文件?????????187??2018-03-15?08:01??ArcPointTest\ArcPointTest\App.config
?????文件????????3818??2018-03-15?08:11??ArcPointTest\ArcPointTest\ArcPointTest.csproj
?????文件????????2185??2018-03-15?08:35??ArcPointTest\ArcPointTest\MainForm.Designer.cs
?????文件????????6100??2018-03-15?08:35??ArcPointTest\ArcPointTest\MainForm.cs
?????文件????????5817??2018-03-15?08:35??ArcPointTest\ArcPointTest\MainForm.resx
?????文件?????????542??2018-03-15?08:01??ArcPointTest\ArcPointTest\Program.cs
?????目錄???????????0??2018-03-15?08:01??ArcPointTest\ArcPointTest\Properties\
?????文件????????1454??2018-03-15?08:01??ArcPointTest\ArcPointTest\Properties\AssemblyInfo.cs
?????文件????????2854??2018-03-15?08:01??ArcPointTest\ArcPointTest\Properties\Resources.Designer.cs
?????文件????????5612??2018-03-15?08:01??ArcPointTest\ArcPointTest\Properties\Resources.resx
?????文件????????1099??2018-03-15?08:01??ArcPointTest\ArcPointTest\Properties\Settings.Designer.cs
?????文件?????????249??2018-03-15?08:01??ArcPointTest\ArcPointTest\Properties\Settings.settings
?????目錄???????????0??2018-03-15?08:01??ArcPointTest\ArcPointTest\bin\
?????目錄???????????0??2018-03-15?08:22??ArcPointTest\ArcPointTest\bin\Debug\
?????文件???????10752??2018-03-15?08:35??ArcPointTest\ArcPointTest\bin\Debug\ArcPointTest.exe
?????文件?????????187??2018-03-15?08:01??ArcPointTest\ArcPointTest\bin\Debug\ArcPointTest.exe.config
?????文件???????26112??2018-03-15?08:35??ArcPointTest\ArcPointTest\bin\Debug\ArcPointTest.pdb
?????文件???????22984??2018-03-15?08:25??ArcPointTest\ArcPointTest\bin\Debug\ArcPointTest.vshost.exe
?????文件?????????187??2018-03-15?08:01??ArcPointTest\ArcPointTest\bin\Debug\ArcPointTest.vshost.exe.config
?????目錄???????????0??2018-03-15?08:36??ArcPointTest\ArcPointTest\bin\Release\
?????目錄???????????0??2018-03-15?08:01??ArcPointTest\ArcPointTest\obj\
?????目錄???????????0??2018-03-15?08:35??ArcPointTest\ArcPointTest\obj\Debug\
?????文件?????????180??2018-03-15?08:35??ArcPointTest\ArcPointTest\obj\Debug\ArcPointTest.ArcPointTest.resources
?????文件?????????180??2018-03-15?08:11??ArcPointTest\ArcPointTest\obj\Debug\ArcPointTest.Properties.Resources.resources
?????文件?????????742??2018-03-15?08:25??ArcPointTest\ArcPointTest\obj\Debug\ArcPointTest.csproj.FileListAbsolute.txt
?????文件????????1036??2018-03-15?08:35??ArcPointTest\ArcPointTest\obj\Debug\ArcPointTest.csproj.GenerateResource.Cache
?????文件????????2209??2018-03-15?08:01??ArcPointTest\ArcPointTest\obj\Debug\ArcPointTest.csprojResolveAssemblyReference.cache
?????文件???????10752??2018-03-15?08:35??ArcPointTest\ArcPointTest\obj\Debug\ArcPointTest.exe
?????文件???????26112??2018-03-15?08:35??ArcPointTest\ArcPointTest\obj\Debug\ArcPointTest.pdb
............此處省略8個(gè)文件信息
評(píng)論
共有 條評(píng)論