189 8069 5689

vb.net拟合多段线 多段线如何拟合

谁能提供一段vb在CAD中绘制多段线的实例代码作参考!

多线段没画过,

创新互联专注为客户提供全方位的互联网综合服务,包含不限于成都网站建设、做网站、驻马店网络推广、微信小程序开发、驻马店网络营销、驻马店企业策划、驻马店品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联为所有大学生创业者提供驻马店建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com

线倒是画过,二话不说直接上代码你参考一下

绘制边框

Private Sub Command4_Click()

Set acadDoc = acadApp.ActiveDocument

link2

acadDoc.ActiveLayer = acadlay(0)

With adoRes

While Not .EOF

pt1(0) = !X: pt1(1) = !Y: pt1(2) = !z: pt2(0) = !X1: pt2(1) = !Y1: pt2(2) = !z1

draw pt1, pt2

.MoveNext

Wend

End With

pt1(0) = 0: pt1(1) = 0: pt1(2) = 0

pt2(0) = 20: pt2(1) = 10: pt2(2) = 0

draw pt1, pt2

'在坡

pt1(0) = 0: pt1(1) = 0: pt1(2) = 0

pt2(0) = 20: pt2(1) = 10: pt2(2) = 0

draw pt1, pt2

For c = 0 To 50 Step 10

pt1(0) = 0: pt1(1) = c: pt1(2) = 0

pt2(0) = 270: pt2(1) = c: pt2(2) = 0

draw pt1, pt2

Next c

pt1(0) = 20: pt1(1) = 0: pt1(2) = 0

pt2(0) = 20: pt2(1) = 190: pt2(2) = 0

draw pt1, pt2

pt1(0) = 0: pt1(1) = 0: pt1(2) = 0

pt2(0) = 0: pt2(1) = -10: pt2(2) = 0

draw pt1, pt2

pt1(0) = 0: pt1(1) = -10: pt1(2) = 0

pt2(0) = 270: pt2(1) = -10: pt2(2) = 0

draw pt1, pt2

pt1(0) = 270: pt1(1) = -10: pt1(2) = 0

pt2(0) = 270: pt2(1) = 0: pt2(2) = 0

draw pt1, pt2

pt3(0) = 5: pt3(1) = -7

acadDoc.ModelSpace.AddText t, pt3, 4

pt3(0) = 55: pt3(1) = -7

acadDoc.ModelSpace.AddText t1, pt3, 4

a = 0

For c = 60 To 100 Step 10

pt1(0) = 20: pt1(1) = c: pt1(2) = 0

pt2(0) = 23: pt2(1) = c: pt2(2) = 0

draw pt1, pt2

pt1(0) = 10: pt1(1) = c - 1.6: pt1(2) = 0

acadDoc.ModelSpace.AddText a, pt1, 3.2

a = a + 2

Next c

'在图中加入地面高程

acadDoc.ActiveTextStyle = acadDoc.TextStyles.Add("楷体")

pt1(0) = 1: pt1(1) = 13: pt1(2) = 0

Set acadtext = acadDoc.ModelSpace.AddText("地面高程", pt1, 3.2)

Call rote1(acadtext, pt1)

'在图中加入设计高程

Call rote1(acadtext, pt1)

pt1(0) = 1: pt1(1) = 23: pt1(2) = 0

Set acadtext = acadDoc.ModelSpace.AddText("设计高程", pt1, 3.2)

Call rote1(acadtext, pt1)

'在图中加入填挖高

pt1(0) = 1: pt1(1) = 33: pt1(2) = 0

Set acadtext = acadDoc.ModelSpace.AddText("填 挖 高", pt1, 3.2)

Call rote1(acadtext, pt1)

'在图中加入坡度/坡长

pt1(0) = 0: pt1(1) = 5.5: pt1(2) = 0

Set acadtext = acadDoc.ModelSpace.AddText("坡 度", pt1, 3.2)

Call rote1(acadtext, pt1)

pt1(0) = 9: pt1(1) = 1: pt1(2) = 0

Set acadtext = acadDoc.ModelSpace.AddText("坡 长", pt1, 3.2)

Call rote1(acadtext, pt1)

'在图中加入桩号

pt1(0) = 1: pt1(1) = 43: pt1(2) = 0

Set acadtext = acadDoc.ModelSpace.AddText("桩 号", pt1, 3.2)

Call rote1(acadtext, pt1)

Call Command5_Click

End Sub

Private Sub draw(pt1, pt2)

Set AcadLine = acadDoc.ModelSpace.AddLine(pt1, pt2)

acadDoc.Regen acActiveViewport

End Sub

线倒是画过,二话不说直接上代码你参考一下

vb曲线拟合

老弟,公式打不出来的

一般都是用matlab搞定的,它里面有现成的函数供使用的

典型程序解析:

x=[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];%input xi data

y=[1.978 3.28 6.16 7.08 7.34 7.66 9.56 9.48 9.30 11.2]; % input yi data

n=2; % polynomial order

p=polyfit(x, y, n)% polyfit 的输出是一个多项式系数的行向量(拟合二项式的系数)

ezplot('-9.8108*x*x+20.1293*x-0.0317')%对拟合的函数作图

xi=linspace(0,1,100); % x-axis data for plotting

z=polyval(p, xi);% 为了计算在xi数据点的多项式值,调用MATLAB的函数polyval

plot(x,y, 'o' ,x,y,xi,z,':')%在同一个图形里看他们的拟合程度

典型例题:对以下数据分别作二次,三次多项式拟合,并画出图形.

x=1:16;

y=[4, 6.4, 8, 8.4, 9.28, 9.5, 9.7, 9.86, 10, 10.2, 10.32, 10.42, 10.5, 10.55, 10.58, 10.6];

源程序:二次多项式拟合

x=1:1:16;

y=[4, 6.4, 8, 8.4, 9.28, 9.5, 9.7, 9.86, 10, 10.2, 10.32, 10.42, 10.5, 10.55, 10.58, 10.6];

a=polyfit(x,y,2)

a =

-0.0445 1.0711 4.3252

ezplot('-0.0445*x^2+1.0711*x+4.3252')

三次多项式拟合

x=1:1:16;

y=[4, 6.4, 8, 8.4, 9.28, 9.5, 9.7, 9.86, 10, 10.2, 10.32, 10.42, 10.5, 10.55, 10.58, 10.6];

a=polyfit(x,y,3)

a =

0.0060 -0.1963 2.1346 2.5952

ezplot('0.0060*x^3-0.1963*x^2+2.1346*x+2.5952')

VB.NET 简单多线程

多线程一般是不推荐用的,因为线程之间如果有共享资源的话会引起竞争,需要加锁处理;而且线程间没有时序关系,所以你在调试中可能会出现异步处理结束顺序与开始处理顺序不一致的情况(我在调试中已经发现该问题)。

针对你提出的这个问题,采用了多线程处理,利用的是BackgroundWorker也就是异步处理控件进行了处理。

代码已经经过调试通过。欢迎交流,如有问题,留下QQ或其他联系方式。

代码如下,并附程序截图。

‘---------------------------------------------------

Imports System.ComponentModel '导入异步控件命名空间

Public Class Form1

Private howmany As Integer = 10

Private AnalysisNumber(0 To howmany - 1) As BackgroundWorker

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

ListBox1.Items.Clear()

creatNewBackgroundWorker()

addHandle()

startWork()

End Sub

Private Sub creatNewBackgroundWorker()

For i As Integer = 0 To AnalysisNumber.Length - 1

AnalysisNumber(i) = New BackgroundWorker

Next

End Sub

Private Sub addHandle()

For i As Integer = 0 To AnalysisNumber.Length - 1

AddHandler AnalysisNumber(i).DoWork, AddressOf AnalysisNumber_DoWork

AddHandler AnalysisNumber(i).RunWorkerCompleted, AddressOf AnalysisNumber_RunWorkerCompleted

Next

End Sub

Private Sub startWork()

For i As Integer = 0 To 9

Dim temp(0 To 9) As Integer

For j As Integer = 1 To 10

temp(j - 1) = 10 * i + j

Next

AnalysisNumber(i).RunWorkerAsync(temp)

Next

End Sub

Private Sub AnalysisNumber_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)

Dim data As Integer()

data = CType(e.Argument, Integer())

Dim temp As Integer

For i As Integer = 0 To data.Length - 1

temp = data(i)

data(i) = temp * temp

Next

e.Result = data

End Sub

Private Sub AnalysisNumber_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)

Dim data As Integer()

data = CType(e.Result, Integer())

For i As Integer = 0 To data.Length - 1

ListBox1.Items.Add(data(i))

Next

End Sub

End Class


分享题目:vb.net拟合多段线 多段线如何拟合
网页网址:http://jkwzsj.com/article/doedsge.html

其他资讯