當前位置: 首頁>>代碼示例>>Python>>正文


Python Point.distance方法代碼示例

本文整理匯總了Python中Point.Point.distance方法的典型用法代碼示例。如果您正苦於以下問題:Python Point.distance方法的具體用法?Python Point.distance怎麽用?Python Point.distance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Point.Point的用法示例。


在下文中一共展示了Point.distance方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: coords

# 需要導入模塊: from Point import Point [as 別名]
# 或者: from Point.Point import distance [as 別名]
def coords(p):
    return p.x,p.y

if __name__ == '__main__':
    tank1 = Point(0,0)
    tank2 = Point(500,0) # shooter

    # Danger: [Circle C(424.255,742.446), R(628.000)]

    b_power = 3
    b_speed = 20-3*b_power

    t_speed = 8

    distance = tank1.distance(tank2)
    t_min = int(math.ceil(distance / (t_speed + b_speed)))
    t_max = int(math.ceil(distance / abs(b_speed - t_speed)))

    d_min = tank2.distanceTowardPoint(tank1,t_min*t_speed)
    d_max = tank2.distanceTowardPoint(tank1,-t_max*t_speed)
    danger = Circle(d_min.midpoint(d_max),t_speed*(t_min+t_max)/2)
    print("Danger: {0}".format(danger));
    
    bad_loci = []
    loci_param = []
    for t in range(t_min,t_max+1):
        try:
            for isect in Circle(tank1,b_speed*t).intersect(Circle(tank2,t_speed*t)):
                bad_loci.append(coords(isect))
                loci_param.append([t,#/t_max,
開發者ID:mojomojomojo,項目名稱:jubjub_robofab,代碼行數:32,代碼來源:danger_path.py

示例2:

# 需要導入模塊: from Point import Point [as 別名]
# 或者: from Point.Point import distance [as 別名]
from Point import Point
from Rectangle import Rectangle


pointa=Point(10.0,5.0)
pointb=Point(1.0,9.0)

print "the distance of the point "+str(pointa)+" and ther point "+str(pointb)+" is:"+str(pointa.distance(pointb))


rectangle=Rectangle(pointa,pointb)

print rectangle
開發者ID:4ndr01d3,項目名稱:pythonTest,代碼行數:15,代碼來源:usingPoints.py

示例3: print

# 需要導入模塊: from Point import Point [as 別名]
# 或者: from Point.Point import distance [as 別名]
    # turn, move
    currp = start
    turn = 0
    while True:
        path.append(currp);
        print("{0:d},{1:.03f},{2:.03f},{3:.03f}".format(
            turn, h, currp.x, currp.y ))
    
        if turn % 2 == 0:
            h += turnA
        else:
            h += turnB
        h %= 360
        turn += 1
        currp = Point( currp.x + 8*math.cos(math.radians(90-h)),
                       currp.y + 8*math.sin(math.radians(90-h)) )

        if currp == start:
            break
        
    print("{0:d},{1:.03f},{2:.03f},{3:.03f}".format(
        turn, h, currp.x, currp.y ))

    x = np.array([ p.x for p in path ])
    y = np.array([ p.y for p in path ])

    center = Point(np.mean(x),np.mean(y))
    radius = np.mean([ center.distance(p) for p in path ])

    print("C{0}, r({1:.02f})".format(center,radius))
開發者ID:mojomojomojo,項目名稱:jubjub_robofab,代碼行數:32,代碼來源:circular_anal.py

示例4: main

# 需要導入模塊: from Point import Point [as 別名]
# 或者: from Point.Point import distance [as 別名]
def main():
    p1 = Point(1.3, 2.5)
    p2 = Point(0.9, 2.8)
    print(p1.distance(p2))
    return 0
開發者ID:bizatheo,項目名稱:training-material,代碼行數:7,代碼來源:point_class_swig.py


注:本文中的Point.Point.distance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。