本文整理汇总了Python中Vector.Vector.distance方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.distance方法的具体用法?Python Vector.distance怎么用?Python Vector.distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector.Vector
的用法示例。
在下文中一共展示了Vector.distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Sample
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import distance [as 别名]
class Sample(object):
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# P U B L I C F U N C T I O N S
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __init__(self, *args):
self.time = 0
self.position = Vector()
if len(args) == 1:
if isinstance( args[0], Sample ):
self.time = args[0].time
self.position = copy( args[0].position )
elif len(args) == 2:
if isinstance( args[0], float ) or isinstance( args[0], int ):
self.time = args[0]
if isinstance( args[1], Vector ):
self.position = copy( args[1] )
elif len(args) == 4:
if isinstance( args[0], float ) or isinstance( args[0], int ):
self.time = args[0]
self.position = Vector( args[1], args[2], args[3] )
def __str__(self):
return str( self.time ) + "\t" + str(self.position)
def distance(self, otherSample):
if isinstance( otherSample, Sample ):
return self.position.distance(otherSample.position)