bluefires 发表于 2006-6-17 22:01:00

请教一个算法?求点坐标的

<P></P>
<P>已知一个图形,如上,在其内部有一个点,知道点的坐标,有没有什么办法,可以知道那个图形的五个定点的坐标,这个图形在AUTOCAD中是二维的。大家有没有什么好的算法或办法或源代码?谢谢了</P>

xinghesnak 发表于 2006-6-19 09:02:00

<P><BR>Private Type MyType<BR>&nbsp;&nbsp;&nbsp; X As Double<BR>&nbsp;&nbsp;&nbsp; Y As Double<BR>&nbsp;&nbsp;&nbsp; Z As Double<BR>End Type</P>
<P>Sub main()<BR>Dim SelP(2) As Double '相当于内部的点<BR>Dim GetP() As MyType&nbsp; '返回的边界定点数组<BR>ReDim GetP(0)</P>
<P>SelP(0) = 250: SelP(1) = 150: SelP(2) = 0<BR>ThisDrawing.SendCommand "-boundary" &amp; vbCr &amp; SelP(0) &amp; "," &amp; SelP(1) &amp; vbCr &amp; vbCr<BR>Dim Obj As Object<BR>Set Obj = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)</P>
<P>Dim i As Integer<BR>Dim Data As Variant<BR>Data = Obj.Coordinates<BR>For i = 0 To (UBound(Data) + 1) / 2 - 1<BR>&nbsp;&nbsp;&nbsp; If i &lt;&gt; 0 Then ReDim Preserve GetP(UBound(GetP) + 1)<BR>&nbsp;&nbsp;&nbsp; GetP(UBound(GetP)).X = Data(2 * i)<BR>&nbsp;&nbsp;&nbsp; GetP(UBound(GetP)).Y = Data(2 * i + 1)<BR>&nbsp;&nbsp;&nbsp; GetP(UBound(GetP)).Z = 0<BR>Next<BR>End Sub</P>
<P>&nbsp;</P>
页: [1]
查看完整版本: 请教一个算法?求点坐标的