4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【覚書】回転した場合の座標位置の計算方法

Posted at

覚書

プログラミングするときについ忘れてぐぐるので残しておく。
なぜそうなるか?という説明は読むのが面倒なのでどうすればいいかだけ書いておく。なぜそうなるか?というのを知りたい場合は三角関数でぐぐってください。
学校で習う三角関数もちゃんと役に立つでしょ。:smirk:

回転した座標の位置

(x, y) 座標の点を(cx, cy)を中心に r 度反時計回りに回転させた場合の座標(x', y')

x' = (x - cx) * cos(r) - (y - cy) * sin(r) + cx
y' = (x - cx) * sin(r) + (y - cy) * cos(r) + cy

(x', y')

として求める。

画像の中心

画像の中心点は、幅wの半分, 高さhの半分が中心なので

center = (w/2, h/2)

となる。

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?