import math
class Point:
def __init__(self,x=0,y=0):
self.x=x
self.y=y
class Line(Point):
def getLen(self,p1,p2):
r=math.sqrt(((p1.x-p2.x)**2)+(p1.y-p2.y)**2)
return r
p1=Point(1,1)
p2=Point(4,5)
l=Line()
hh=l.getLen(p1,p2)
print(hh)
写点类,再写直线类,算两点间的距离
最新推荐文章于 2021-02-25 03:23:51 发布