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

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

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

問題描述

我正在嘗試制作一種紙牌散開的紙牌游戲.現在使用具有功能的 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);

所以有了這個,我可以輕松地制作我的粉絲效果.問題是知道哪張卡在鼠標下面.為此,我想到了進行多邊形碰撞測試.我只是不確定如何旋轉卡片上的 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),然后旋轉,再添加點.

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

未經測試:

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;
}

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

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

相關文檔推薦

What is the fastest way to transpose a matrix in C++?(在 C++ 中轉置矩陣的最快方法是什么?)
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) 嗎?)
主站蜘蛛池模板: 一区二区在线 | 一区二区三区免费 | 91手机精品视频 | 欧美一区二区另类 | 国产在线一区二区三区 | 久久精品1 | 久久a久久 | 国产精品视频不卡 | 人人爽人人爽 | 中文字幕一区二区视频 | 春色av| 国产欧美精品 | 国产精品免费观看 | 午夜视频在线观看网站 | 久久毛片 | 亚洲国产精品久久久久婷婷老年 | 国产一级片精品 | 久久精品国产清自在天天线 | 亚洲性网| 久久久片 | 国产91久久久久久 | 99久久精品一区二区毛片吞精 | 久久久久中文字幕 | 国产精品久久久久久久午夜 | 亚洲精品一区在线 | 婷婷综合在线 | 国产黄色大片 | 夜夜爽夜夜操 | www,黄色,com| 日韩一级 | 国产欧美在线 | 精品一区二区久久久久久久网站 | 国产精品mv在线观看 | 97精品超碰一区二区三区 | 国产97碰免费视频 | 91久久精品国产91久久性色tv | 精品免费 | 我要看黄色录像一级片 | 亚洲精品乱码 | 日韩精品一区二区三区中文字幕 | 国产免费视频在线 |