Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ 図形の平行移動 | 幾何学的変換
Pythonによる幾何モデリング

図形の平行移動

メニューを表示するにはスワイプしてください

平行移動は、図形のすべての点を指定された方向に同じ距離だけ移動させる基本的な幾何学的変換です。数学的には、図形の各点に一定のベクトルを加えることを意味します。

  • ある点の座標が (x, y) で、その点をベクトル (dx, dy) だけ移動させたい場合、新しい座標は (x + dx, y + dy) となります。この操作は図形の大きさ向きを保ち、図形全体を新しい位置に移動させるだけです。

例えば、頂点が (1, 2)(3, 5)(5, 4) にある三角形があるとします。この三角形をベクトル (2, -1) で平行移動すると、新しい頂点は (3, 1)(5, 4)(7, 3) になります。各頂点は右に2単位、下に1単位移動します。この単純な加算は、点の集合として表現される任意の図形に適用できます。

123456789101112131415161718
def translate_polygon(polygon, dx, dy): """ Translates a polygon by a vector (dx, dy). Args: polygon: List of (x, y) tuples representing the polygon's vertices. dx: Translation in the x-direction. dy: Translation in the y-direction. Returns: List of (x, y) tuples representing the translated polygon. """ return [(x + dx, y + dy) for (x, y) in polygon] # Example usage: triangle = [(1, 2), (3, 5), (5, 4)] translated_triangle = translate_polygon(triangle, 2, -1) print("Translated triangle:", translated_triangle)
question mark

平行移動について正しい記述はどれですか?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 2.  1

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 2.  1
some-alt