请教一个算法:如何求平面坐标系中,各个离散的点到正多边形(正三角形、正五边形、正六边形)的距离的标准偏差》
请教一个算法:如何求平面坐标系中,各个离散的点到正多边形(正三角形、正五边形、正六边形)的距离的标准偏差。已知有很多离散的点,需要首先一一的求出这些离散的点到正多边形(正三角形、正五边形、正六边形)的距离,然后将这些距离求出标准偏差。
图形很简单,如附图所示。
画出正多边形的算法,已经知道,如下所示:
CalcPolygonPoints PictureBoxShapePoints(), PolygonPointsNumber, RadiusPixel
Polygon Obj.hDC, PictureBoxShapePoints(1), PolygonPointsNumber
Private Sub CalcPolygonPoints(ByRef Points() As POINTAPI, ByVal N As Integer, ByVal Radius As Single)
Dim Angle As Single
Dim DivideAngle As Single
Angle = -PI / 2
DivideAngle = 2 * PI / N
Points(1).X = CenterX
Points(1).Y = CenterY - Radius
Dim i As Integer
For i = 2 To N
Angle = Angle + DivideAngle
Points(i).X = Int(CenterX + Radius * Cos(Angle) - 0.5)
Points(i).Y = Int(CenterY + Radius * Sin(Angle) - 0.5)
Next
End Sub
很简单的方法,可以画出正多边形,但是求距离的标准偏差,就不简单了..............
恳请高人赐教!!!