久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

圍繞另一個點旋轉(zhuǎn)一個點 (2D)

Rotating a point about another point (2D)(圍繞另一個點旋轉(zhuǎn)一個點 (2D))
本文介紹了圍繞另一個點旋轉(zhuǎn)一個點 (2D)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試制作一種紙牌散開的紙牌游戲.現(xiàn)在使用具有功能的 Allegro API 來顯示它:

I'm trying to make a card game where the cards fan out. Right now to display it Im using the Allegro API which has a function:

al_draw_rotated_bitmap(OBJECT_TO_ROTATE,CENTER_X,CENTER_Y,X
        ,Y,DEGREES_TO_ROTATE_IN_RADIANS);

所以有了這個,我可以輕松地制作我的粉絲效果.問題是知道哪張卡在鼠標下面.為此,我想到了進行多邊形碰撞測試.我只是不確定如何旋轉(zhuǎn)卡片上的 4 個點來組成多邊形.我基本上需要做和Allegro一樣的操作.

so with this I can make my fan effect easily. The problem is then knowing which card is under the mouse. To do this I thought of doing a polygon collision test. I'm just not sure how to rotate the 4 points on the card to make up the polygon. I basically need to do the same operation as Allegro.

比如卡片的4點是:

card.x

card.y

card.x + card.width

card.y + card.height

我需要一個類似的功能:

I would need a function like:

POINT rotate_point(float cx,float cy,float angle,POINT p)
{
}

謝謝

推薦答案

先減去樞軸點(cx,cy),然后旋轉(zhuǎn),再添加點.

First subtract the pivot point (cx,cy), then rotate it, then add the point again.

未經(jīng)測試:

POINT rotate_point(float cx,float cy,float angle,POINT p)
{
  float s = sin(angle);
  float c = cos(angle);

  // translate point back to origin:
  p.x -= cx;
  p.y -= cy;

  // rotate point
  float xnew = p.x * c - p.y * s;
  float ynew = p.x * s + p.y * c;

  // translate point back:
  p.x = xnew + cx;
  p.y = ynew + cy;
  return p;
}

這篇關于圍繞另一個點旋轉(zhuǎn)一個點 (2D)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

What is the fastest way to transpose a matrix in C++?(在 C++ 中轉(zhuǎn)置矩陣的最快方法是什么?)
Sorting zipped (locked) containers in C++ using boost or the STL(使用 boost 或 STL 在 C++ 中對壓縮(鎖定)容器進行排序)
Image Processing: Algorithm Improvement for #39;Coca-Cola Can#39; Recognition(圖像處理:Coca-Cola Can 識別的算法改進)
How do I construct an ISO 8601 datetime in C++?(如何在 C++ 中構建 ISO 8601 日期時間?)
Sort list using STL sort function(使用 STL 排序功能對列表進行排序)
Is list::size() really O(n)?(list::size() 真的是 O(n) 嗎?)
主站蜘蛛池模板: 亚洲欧美另类在线观看 | 国产一区二区福利 | 欧美www| 成人精品在线 | 黄色三级视频网站 | 日本香蕉视频 | 欧美日韩大片 | 一级淫片观看 | 日韩中文字幕视频 | 日产久久视频 | 久久在线免费视频 | av大全在线观看 | 亚洲另类色图 | 欧美日韩毛片 | 亚洲高清在线播放 | 人人九九精 | 亚洲免费视频观看 | 日本三级大片 | 国产高清在线观看 | 精品国产三级 | 激情视频网 | 久久精品一二三 | 深夜福利网址 | 成人片在线播放 | 成人在线国产 | 成人毛片在线 | 日本一级片在线观看 | 中文字幕在线视频播放 | 亚洲第一av | 国产精品网站在线观看 | 欧美日韩一区二区在线观看 | 久久久久久久久久国产精品 | 精品免费 | 欧美一级做性受免费大片免费 | 黄色一区二区三区 | 91成人在线观看喷潮蘑菇 | 久青草影院 | 久久av影院 | 国产精品一区二区三区四区 | 国产成人一区二区三区 | 欧美偷拍精品 |