2017-10-03 7 views
1

を次のように私はそのインデックスを有するランダムな位置のセットを有する:さらにいくつかの数学演算後座標古い取り外しとそのインデックスに新しいものを追加 - パイソン

pos = {0: (65, 0), 1: (143, 96), 2: (2, 45), 3: (128, 19), 4: (91, 34), 5: (105, 127), 6: (80, 29), 7: (148, 134), 8: (53.0, 46.5), 9: (116.0, 33.5), 10: (104.5, 87.5), 11: (62.25, 28.25), 12: (69.25, 74.75), 13: (56.75, 25.75), 14: (90.75, 78.25), 15: (93.75, 21.75), 16: (100.75, 68.25), 17: (88.25, 19.25), 18: (122.25, 71.75), 19: (116.5, 98.75)} 

、私は発見した点の座標[8, 17, 20, 9, 11, 21, 10, 19, 14, 22, 16]は今、私はposからこれらのインデックスに古い座標対応を削除し、その中に新しいものを追加する必要が

[(64.933003914056954, 73.512353385691156), (67.609354584781386, 29.084825707397332), (65.055487297822125, 71.479138365156629), (65.634499205445252, 61.867750510493728), (65.551876571641429, 63.239283293792454), (66.366807024791072, 49.711182456213727), (65.485681419116816, 64.338102471328327), (65.308178284791879, 67.284467319880079), (67.031361074876017, 38.679499846625028), (67.286696006705057, 34.440985282832173), (65.062957777139445, 71.355123241241017)]. 

としてそれに応じて変更されています。 これをPythonでどうやって行うことができますか?

答えて

2

あなたはこれを試すことができます。

pos = {0: (65, 0), 1: (143, 96), 2: (2, 45), 3: (128, 19), 4: (91, 34), 5: (105, 127), 6: (80, 29), 7: (148, 134), 8: (53.0, 46.5), 9: (116.0, 33.5), 10: (104.5, 87.5), 11: (62.25, 28.25), 12: (69.25, 74.75), 13: (56.75, 25.75), 14: (90.75, 78.25), 15: (93.75, 21.75), 16: (100.75, 68.25), 17: (88.25, 19.25), 18: (122.25, 71.75), 19: (116.5, 98.75)} 
points = [8, 17, 20, 9, 11, 21, 10, 19, 14, 22, 16] 
val = [(64.933003914056954, 73.512353385691156), (67.609354584781386, 29.084825707397332), (65.055487297822125, 71.479138365156629), (65.634499205445252, 61.867750510493728), (65.551876571641429, 63.239283293792454), (66.366807024791072, 49.711182456213727), (65.485681419116816, 64.338102471328327), (65.308178284791879, 67.284467319880079), (67.031361074876017, 38.679499846625028), (67.286696006705057, 34.440985282832173), (65.062957777139445, 71.355123241241017)] 
for i, key in enumerate(points): 
    pos[key] = val[i] 

posは次のようになります。

{0: (65, 0), 
1: (143, 96), 
2: (2, 45), 
3: (128, 19), 
4: (91, 34), 
5: (105, 127), 
6: (80, 29), 
7: (148, 134), 
8: (64.93300391405695, 73.51235338569116), 
9: (65.63449920544525, 61.86775051049373), 
10: (65.48568141911682, 64.33810247132833), 
11: (65.55187657164143, 63.239283293792454), 
12: (69.25, 74.75), 
13: (56.75, 25.75), 
14: (67.03136107487602, 38.67949984662503), 
15: (93.75, 21.75), 
16: (65.06295777713945, 71.35512324124102), 
17: (67.60935458478139, 29.084825707397332), 
18: (122.25, 71.75), 
19: (65.30817828479188, 67.28446731988008), 
20: (65.05548729782213, 71.47913836515663), 
21: (66.36680702479107, 49.71118245621373), 
22: (67.28669600670506, 34.44098528283217)} 
+0

おかげで、Hejunを!それはうまくいった! – ccc

関連する問題