本文整理汇总了Python中Vector.Vector.length方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.length方法的具体用法?Python Vector.length怎么用?Python Vector.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector.Vector
的用法示例。
在下文中一共展示了Vector.length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_min_new
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import length [as 别名]
def find_min_new (a,b,c,d):
ab = Vector(a, b)
cd = Vector(c, d)
res_intersection = ab.is_intersection(cd)
if res_intersection == 0:
print("One end of segment belongs another segment")
return ab.length()
elif res_intersection < 0:
print("Not intersection")
return ab.length()
else:
bd = Vector(b, d)
ad = Vector(a, d)
cb = Vector(c, b)
ac = Vector(a, c)
print("Intersection")
return min(ac.length()+cb.length(), ad.length()+bd.length())
示例2: find_min
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import length [as 别名]
def find_min(a, b, c, d):
ab = Vector(a, b)
ac = Vector(a, c)
ad = Vector(a, d)
cd = Vector(c, d)
ca = Vector(c, a)
cb = Vector(c, b)
bd = Vector(b, d)
if intersect(a,b,c,d):
print("Not intersection")
return ab.length()
elif ab.cros_product(ac)*ab.cros_product(ad) <= 0 and cd.cros_product(ca)*cd.cros_product(cb) <= 0:
print("Intersection")
return min(ac.length()+cb.length(), ad.length()+bd.length())
else:
print("Not intersection")
return ab.length()