2017-03-07 5 views
0

sympyでサークルの中心のX値をインクリメントする単純な関数を作成するのに苦労します。ここに私のコードは次のとおりです。AttributeError:sympyでサークルのX値をインクリメントしようとしたときに属性を設定できません

test_center=Point (1,2) 
test_circle = Circle (test_center, 1) 

def travel (circle, distance): 

    circle.center.x += distance 
    return circle.center.x 

travel (test_circle,1) 
print(test_circle) 

私は戻って何を得る:

ライン16、旅行

circle.center.x += distance AttributeError: can't set attribute

に任意の助けをいただければ幸いです!あなたは翻訳機能を使用して円を移動したい場合は

+0

私はあなたが受け入れ答えをマークしていただければ幸いです。 –

答えて

1

変数circle.center.xは、割り当てることはできません。

from sympy import Point, Circle 

test_center=Point (1,2) 
test_circle = Circle (test_center, 1) 

def travel (circle, distance): 
    return circle.translate(x=distance) 


test_circle = travel(test_circle,1) 
print(test_circle) 
関連する問題