chengw 发表于 2011-8-30 20:43:33

求点的距离

已知一个点(Point3d pt)和点集合(Point3dCollectionpts),求点到点集合距离最短的点。

cdinten 发表于 2011-8-31 07:39:55

double min=p0.GetDistanceTo(point3dcollenction);
foreach(point3d p in pointedCollection)
{
    if(min>p0.GetDistanceTo(p))
      min=p0.GetDistanceTo(p);
}
你要注意修改大小写,记不太清楚Point3d的方法是不是GetDistanceTo还是DistanceTo了……

chengw 发表于 2011-8-31 09:27:48

cdinten 发表于 2011-8-31 07:39 static/image/common/back.gif
double min=p0.GetDistanceTo(point3dcollenction);
foreach(point3d p in pointedCollection)
{


O(∩_∩)O谢谢

cdinten 发表于 2011-8-31 22:02:36

chengw 发表于 2011-8-31 09:27 static/image/common/back.gif
O(∩_∩)O谢谢

my pleasure~

guohq 发表于 2011-9-2 00:25:03

用Linq就一句:

dim minDistance = (from objPt in pts select pt.DistanceTo(objpt) ).min

chengw 发表于 2011-9-2 09:22:52

guohq 发表于 2011-9-2 00:25 static/image/common/back.gif
用Linq就一句:

dim minDistance = (from objPt in pts select pt.DistanceTo(objpt) ).min

谢谢你的回答、、、
页: [1]
查看完整版本: 求点的距离