发布时间:2019-09-26 09:10:00编辑:auto阅读(2734)
参考:http://blog.csdn.net/abcjennifer/article/details/7584628
# -*- coding: utf-8 -*- class Point(object): x =0 y= 0 # 定义构造方法 def __init__(self, x=0, y=0): self.x = x self.y = y class Line(object): # a=0 # b=0 # c=0 def __init__(self, p1, p2): self.p1 = p1 self.p2 = p2 def GetLinePara(line): line.a =line.p1.y - line.p2.y; line.b = line.p2.x - line.p1.x; line.c = line.p1.x *line.p2.y - line.p2.x * line.p1.y; def GetCrossPoint(l1,l2): GetLinePara(l1); GetLinePara(l2); d = l1.a * l2.b - l2.a * l1.b p=Point() p.x = (l1.b * l2.c - l2.b * l1.c)*1.0 / d p.y = (l1.c * l2.a - l2.c * l1.a)*1.0 / d return p; p1=Point(1,1) p2=Point(3,3) line1=Line(p1,p2) p3=Point(2,3.1) p4=Point(3.1,2) line2=Line(p3,p4) Pc = GetCrossPoint(line1,line2); print("Cross point:", Pc.x, Pc.y);
上一篇: Python 做自动化测试环境搭建
下一篇: sublime text 3 + pyt
47751
46255
37137
34644
29234
25894
24763
19867
19429
17918
5721°
6325°
5843°
5893°
6994°
5832°
5852°
6366°
6320°
7685°