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

<small id='iwrt6'></small><noframes id='iwrt6'>

<i id='iwrt6'><tr id='iwrt6'><dt id='iwrt6'><q id='iwrt6'><span id='iwrt6'><b id='iwrt6'><form id='iwrt6'><ins id='iwrt6'></ins><ul id='iwrt6'></ul><sub id='iwrt6'></sub></form><legend id='iwrt6'></legend><bdo id='iwrt6'><pre id='iwrt6'><center id='iwrt6'></center></pre></bdo></b><th id='iwrt6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='iwrt6'><tfoot id='iwrt6'></tfoot><dl id='iwrt6'><fieldset id='iwrt6'></fieldset></dl></div>
  • <legend id='iwrt6'><style id='iwrt6'><dir id='iwrt6'><q id='iwrt6'></q></dir></style></legend>
      <tfoot id='iwrt6'></tfoot>

        • <bdo id='iwrt6'></bdo><ul id='iwrt6'></ul>

        如何在Javascript中計(jì)算二維旋轉(zhuǎn)

        How to calculate rotation in 2D in Javascript(如何在Javascript中計(jì)算二維旋轉(zhuǎn))
          <legend id='2k7RF'><style id='2k7RF'><dir id='2k7RF'><q id='2k7RF'></q></dir></style></legend>

                <bdo id='2k7RF'></bdo><ul id='2k7RF'></ul>

                  <tbody id='2k7RF'></tbody>

                  <i id='2k7RF'><tr id='2k7RF'><dt id='2k7RF'><q id='2k7RF'><span id='2k7RF'><b id='2k7RF'><form id='2k7RF'><ins id='2k7RF'></ins><ul id='2k7RF'></ul><sub id='2k7RF'></sub></form><legend id='2k7RF'></legend><bdo id='2k7RF'><pre id='2k7RF'><center id='2k7RF'></center></pre></bdo></b><th id='2k7RF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2k7RF'><tfoot id='2k7RF'></tfoot><dl id='2k7RF'><fieldset id='2k7RF'></fieldset></dl></div>

                  <small id='2k7RF'></small><noframes id='2k7RF'>

                  <tfoot id='2k7RF'></tfoot>
                • 本文介紹了如何在Javascript中計(jì)算二維旋轉(zhuǎn)的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問題描述

                  我對(duì)三角學(xué)不是很熟悉,但我只有兩個(gè)點(diǎn)可以在 2D 中旋轉(zhuǎn):

                  I am not so familiar trigonometry, but I have only two points to rotate in 2D:

                                      *nx, ny
                                 .     -
                            .           -
                       .  angle          -
                  *cx,cy.................*x,y
                  

                  cx, cy = 旋轉(zhuǎn)中心
                  x,y = 當(dāng)前 x,y
                  nx, ny = 新坐標(biāo)

                  cx, cy = rotation center
                  x,y = current x,y
                  nx, ny = new coordinates

                  如何計(jì)算某個(gè)角度的新點(diǎn)?

                  How to calculate new points in a certain angle?

                  推薦答案

                  function rotate(cx, cy, x, y, angle) {
                      var radians = (Math.PI / 180) * angle,
                          cos = Math.cos(radians),
                          sin = Math.sin(radians),
                          nx = (cos * (x - cx)) + (sin * (y - cy)) + cx,
                          ny = (cos * (y - cy)) - (sin * (x - cx)) + cy;
                      return [nx, ny];
                  }
                  

                  前兩個(gè)參數(shù)是中心點(diǎn)(第二個(gè)點(diǎn)將圍繞其旋轉(zhuǎn)的原點(diǎn))的 X 和 Y 坐標(biāo).接下來(lái)的兩個(gè)參數(shù)是我們將要旋轉(zhuǎn)的點(diǎn)的坐標(biāo).最后一個(gè)參數(shù)是角度,以度為單位.

                  The first two parameters are the X and Y coordinates of the central point (the origin around which the second point will be rotated). The next two parameters are the coordinates of the point that we'll be rotating. The last parameter is the angle, in degrees.

                  作為示例,我們將取點(diǎn) (2, 1) 并將其圍繞點(diǎn) (1, 1) 順時(shí)針旋轉(zhuǎn) 90 度.

                  As an example, we'll take the point (2, 1) and rotate it around the point (1, 1) by 90 degrees clockwise.

                  rotate(1, 1, 2, 1, 90);
                  // > [1, 0]
                  

                  關(guān)于這個(gè)函數(shù)的三個(gè)注意事項(xiàng):

                  Three notes about this function:

                  1. 對(duì)于順時(shí)針旋轉(zhuǎn),最后一個(gè)參數(shù)angle應(yīng)該是正數(shù).對(duì)于逆時(shí)針旋轉(zhuǎn)(如您提供的圖表),它應(yīng)該是負(fù)數(shù).

                  1. For clockwise rotation, the last parameter angle should be positive. For counterclockwise rotation (like in the diagram you provided), it should be negative.

                  請(qǐng)注意,即使您提供的參數(shù)應(yīng)該產(chǎn)生一個(gè)坐標(biāo)是整數(shù)的點(diǎn)——即將點(diǎn) (5, 0) 圍繞原點(diǎn) (0, 0) 旋轉(zhuǎn) 90 度,這應(yīng)該產(chǎn)生 (0, -5) -- JavaScript 的舍入行為意味著任何一個(gè)坐標(biāo)仍然可能是一個(gè)非常接近預(yù)期整數(shù)的值,但仍然是一個(gè)浮點(diǎn)數(shù).例如:

                  Note that even if you provide arguments that should yield a point whose coordinates are whole numbers -- i.e. rotating the point (5, 0) by 90 degrees about the origin (0, 0), which should yield (0, -5) -- JavaScript's rounding behavior means that either coordinate could still be a value that's frustratingly close to the expected whole number, but is still a float. For example:

                  rotate(0, 0, 5, 0, 90);
                  // > [3.061616997868383e-16, -5]
                  

                  因此,結(jié)果數(shù)組的兩個(gè)元素都應(yīng)該是浮點(diǎn)數(shù).您可以根據(jù)需要使用 Math.round()Math.ceil()Math.floor() 將它們轉(zhuǎn)換為整數(shù).

                  For this reason, both elements of the resulting array should be expected as a float. You can convert them to integers using Math.round(), Math.ceil(), or Math.floor() as needed.

                  最后,請(qǐng)注意,此函數(shù)假定 笛卡爾坐標(biāo)系,這意味著值當(dāng)您在坐標(biāo)平面中向上"時(shí),Y 軸上的值會(huì)變得更高.在 HTML/CSS 中,Y 軸是倒置的——當(dāng)您將頁(yè)面向下移動(dòng)時(shí),Y 軸上的值會(huì)變高.

                  Finally, note that this function assumes a Cartesian coordinate system, meaning that values on the Y axis become higher as you go "up" in the coordinate plane. In HTML / CSS, the Y axis is inverted -- values on the Y axis become higher as you move down the page.

                  這篇關(guān)于如何在Javascript中計(jì)算二維旋轉(zhuǎn)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 ajax 調(diào)用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無(wú)法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)

                    <tbody id='Cw77v'></tbody>

                    • <tfoot id='Cw77v'></tfoot><legend id='Cw77v'><style id='Cw77v'><dir id='Cw77v'><q id='Cw77v'></q></dir></style></legend>
                        <bdo id='Cw77v'></bdo><ul id='Cw77v'></ul>
                          <i id='Cw77v'><tr id='Cw77v'><dt id='Cw77v'><q id='Cw77v'><span id='Cw77v'><b id='Cw77v'><form id='Cw77v'><ins id='Cw77v'></ins><ul id='Cw77v'></ul><sub id='Cw77v'></sub></form><legend id='Cw77v'></legend><bdo id='Cw77v'><pre id='Cw77v'><center id='Cw77v'></center></pre></bdo></b><th id='Cw77v'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Cw77v'><tfoot id='Cw77v'></tfoot><dl id='Cw77v'><fieldset id='Cw77v'></fieldset></dl></div>

                          <small id='Cw77v'></small><noframes id='Cw77v'>

                            主站蜘蛛池模板: 在线中文字幕视频 | 国产亚洲精品美女久久久久久久久久 | 精品国产欧美一区二区三区不卡 | 国产精品一区二区三区久久久 | 亚洲人成人一区二区在线观看 | 岛国二区| 亚洲一区二区黄 | 在线看亚洲 | 在线观看中文字幕 | 国产精品一区二区三 | 国产一区二区不卡 | 91一区二区| 四虎永久免费在线 | 国产精品色av | 久久精品久久久久久 | 亚洲黄色av网站 | 亚洲精品久久久久中文字幕二区 | 羞羞的视频免费观看 | 国产精品高潮呻吟久久av野狼 | 在线视频一区二区 | 久久91 | 亚洲日本一区二区三区四区 | 天天射中文 | 99综合 | 欧美日韩精品国产 | 午夜激情视频 | 青青草一区二区三区 | 欧美成人免费在线视频 | 国产高清视频在线播放 | 色婷婷综合久久久中字幕精品久久 | 久久久久久九九九九 | 午夜小电影 | 丝袜美腿一区二区三区动态图 | 国产中文区二幕区2012 | 日韩国产在线观看 | 国产精品久久久久久久久久久久 | 久久亚洲一区二区三区四区 | 久久久日韩精品一区二区三区 | 国产免费一区二区三区 | 国产午夜精品久久久 | av中文字幕在线播放 |