资源简介
贝泽尔曲线 C# 2008实现。实现方法是利用贝泽尔曲线的数学定义。
代码片段和文件信息
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 ChapterFour
{
public partial class ChapterFour : Form
{
private int pointNum;
private List points;
private Point []pointp;
public ChapterFour()
{
pointNum = 0;
points = new List();
InitializeComponent();
this.polygonButton.Enabled = false;
this.drawButton.Enabled = false;
this.cleanButton.Enabled = false;
}
public void Bezier(List p int n) //生成Bezier曲线
{
Point CurrentP;
int x y i j k = 512;
double t t1 u v;
double temp temp1 temp2 bi;
Graphics myGraphics = this.drawingLabel.CreateGraphics();
Pen myPen = new Pen(Color.Blue 1);
CurrentP = p.ElementAt(0);
t = 1.0 / k;
for (j = 1; j < k; j++)
{
t1 = j * t;
u = t1;
v = 1 - u;
x = 0;
y = 0;
for (i = 0; i <= n; i++)
{
temp = (double)fac(n) / fac(i) / fac(n - i);
temp1 = powi(u i);
temp2 = powi(v n - i);
bi = temp * temp1 * temp2;
x = (int)((double)x + bi * (double)p.ElementAt(i).X);
y = (int)((double)y + bi * (double)p.ElementAt(i).Y);
}
myGraphics.DrawLine(myPen CurrentP.X CurrentP.Y x y);
CurrentP = new Point(x y);
}
myGraphics.DrawLine(myPen CurrentP.X CurrentP.Y p.ElementAt(n).X p.ElementAt(n).Y);
}
private void drawingLabel_Click(object sender EventArgs e)
{
Point CurrentPoint;
Graphics myGraphics = this.drawingLabel.CreateGraphics();
Pen myPen = new Pen(Color.Red 1);
this.polygonButton.Enabled = true;
if(pointNum == 0)
myGraphics.DrawString(“当前状态:确定特征多边形顶点,按“生成特征多边形”键,生成特征多边形“ new Font(“黑体“ 10 Fontstyle.Bold) new SolidBrush(Color.Black) 0 20);
CurrentPoint = PointToClient(Control.MousePosition);
points.Add(CurrentPoint);
pointNum += 1;
myGraphics.DrawLine(myPen CurrentPoint.X - 2 CurrentPoint.Y - 2 CurrentPoint.X + 2 CurrentPoint.Y + 2);
myGraphics.DrawLine(myPen CurrentPoint.X - 2 CurrentPoint.Y + 2 CurrentPoint.X + 2 CurrentPoint.Y - 2);
}
private void polygonButton_Click(object sender EventArgs e)
{
String strPointNum strBezierFac;
Graphics myGraphics = this.drawingLabel.CreateGra
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-10-19 19:05 ChapterFour\
目录 0 2011-10-19 19:05 ChapterFour\ChapterFour\
文件 927 2011-10-15 11:31 ChapterFour\ChapterFour.sln
文件 15360 2011-10-19 19:06 ChapterFour\ChapterFour.suo
目录 0 2011-10-19 19:05 ChapterFour\ChapterFour\bin\
目录 0 2011-10-19 19:05 ChapterFour\ChapterFour\bin\Debug\
文件 13312 2011-10-15 14:19 ChapterFour\ChapterFour\bin\Debug\ChapterFour.exe
文件 28160 2011-10-15 14:19 ChapterFour\ChapterFour\bin\Debug\ChapterFour.pdb
文件 14328 2011-10-19 19:06 ChapterFour\ChapterFour\bin\Debug\ChapterFour.vshost.exe
文件 490 2007-07-21 02:33 ChapterFour\ChapterFour\bin\Debug\ChapterFour.vshost.exe.manifest
目录 0 2011-10-19 19:05 ChapterFour\ChapterFour\bin\Release\
文件 6226 2011-10-15 14:19 ChapterFour\ChapterFour\ChapterFour.cs
文件 3763 2011-10-15 11:36 ChapterFour\ChapterFour\ChapterFour.csproj
文件 74 2011-10-15 11:31 ChapterFour\ChapterFour\ChapterFour.csproj.user
文件 7550 2011-10-15 13:56 ChapterFour\ChapterFour\ChapterFour.Designer.cs
文件 5814 2011-10-15 13:56 ChapterFour\ChapterFour\ChapterFour.resx
目录 0 2011-10-19 19:05 ChapterFour\ChapterFour\obj\
目录 0 2011-10-19 19:05 ChapterFour\ChapterFour\obj\Debug\
文件 180 2011-10-15 13:56 ChapterFour\ChapterFour\obj\Debug\ChapterFour.ChapterFour.resources
文件 670 2011-10-19 19:06 ChapterFour\ChapterFour\obj\Debug\ChapterFour.csproj.FileListAbsolute.txt
文件 853 2011-10-15 13:56 ChapterFour\ChapterFour\obj\Debug\ChapterFour.csproj.GenerateResource.Cache
文件 13312 2011-10-15 14:19 ChapterFour\ChapterFour\obj\Debug\ChapterFour.exe
文件 28160 2011-10-15 14:19 ChapterFour\ChapterFour\obj\Debug\ChapterFour.pdb
文件 180 2011-10-15 11:36 ChapterFour\ChapterFour\obj\Debug\ChapterFour.Properties.Resources.resources
目录 0 2011-10-19 19:05 ChapterFour\ChapterFour\obj\Debug\Refactor\
目录 0 2011-10-19 19:05 ChapterFour\ChapterFour\obj\Debug\TempPE\
目录 0 2011-10-19 19:05 ChapterFour\ChapterFour\obj\Release\
文件 498 2011-10-15 11:31 ChapterFour\ChapterFour\Program.cs
目录 0 2011-10-19 19:05 ChapterFour\ChapterFour\Properties\
文件 1378 2011-10-15 11:30 ChapterFour\ChapterFour\Properties\AssemblyInfo.cs
文件 2873 2011-10-15 11:30 ChapterFour\ChapterFour\Properties\Resources.Designer.cs
............此处省略3个文件信息
评论
共有 条评论