内容发布更新时间 : 2025/3/27 12:56:21星期一 下面是文章的全部内容请认真阅读。
pPoint.PutCoords100,100
IPoint接口的第二个方法QueryCoords(X,Y)(方法,得到该点的坐标)
例子代码: Dim pPoint asIPoint Dim dX asDouble,dYasDouble pPoint.QueryCoordsdX,dY
IPoint接口的第三个方法ConstrainAngle (constraintAngle, anchor, allowOpposite ) (方法,如果第三个参数allowOpposite为True,则将第二个参数anchor这个点作为一个原点,然后以第一个参数 constraintAngle为与x轴的角度,做一条直线,再将调用此参数的点向该直线做垂线并交于一个新点,并将调用此方法的点移动到该点)
例子代码:
'Finds the closespointtolinefrom(0,0)withangles 'defined by stepsofpi/4(Noteallanglesinradians) Dim pApointAsIPoint Dim pNpointAsIPoint Dim piAsDouble Dim dAngleAsDouble Dim iAsLong Set pApoint =NewPoint pi = 4 *Atn(1) dAngle = 0 pApoint.PutCoords 0,0 Set pNpoint =NewPoint For i =0To7
pNpoint.PutCoords 1,0 dAngle = i *pi/4
pNpoint.ConstrainAngle dAngle,pApoint,True
MsgBox\ \ i & \ vbCrLf & pNpoint.X & \ pNpoint.Y Next i
IPoint接口的第四个方法ConstrainDistance(constraintRadius, anchor ) (方法,以第二个参数anchor这个点为圆心,然后以第一个参数constraintRadius为半径做一个圆,将调用此参数的点移动到该点与圆心做线段交于该圆的交点上)
例子代码:
Public Sub t_constraindistance() Dim pPointAsIPoint Dim pNPointAsIPoint Dim dRadiusAsDouble
Set pPoint =NewPoint
pPoint.PutCoords 0,0
Set pNPoint =NewPoint pNPoint.PutCoords 2,2 dRadius = 1.4142135623731
pNPoint.ConstrainDistance dRadius,pPoint
MsgBox \ \ x,y = \ \ pNPoint.Y EndSub
5. 关于IPointArray接口(esriGeometry)
IPointArray接口的第一个方法Add(p) (方法,向该类型的数组变量添加Point)
IPointArray接口的第二个属性Count (只读,获得该数组变量中Point的个数,返回Long类型变量) IPointArray接口的第三个属性Element(Index)(只读,获得该数组变量中位于参数Index索引位置的点Point,返回一个Point类型的变量)
IPointArray接口的第四个方法Insert (Index, p ) (