pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<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="uxpnpia" 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中計算二維旋轉

        How to calculate rotation in 2D in Javascript(如何在Javascript中計算二維旋轉)
          <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="rutprbo" 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中計算二維旋轉的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我對三角學不是很熟悉,但我只有兩個點可以在 2D 中旋轉:

                  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 = 旋轉中心
                  x,y = 當前 x,y
                  nx, ny = 新坐標

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

                  如何計算某個角度的新點?

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

                  前兩個參數是中心點(第二個點將圍繞其旋轉的原點)的 X 和 Y 坐標.接下來的兩個參數是我們將要旋轉的點的坐標.最后一個參數是角度,以度為單位.

                  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.

                  作為示例,我們將取點 (2, 1) 并將其圍繞點 (1, 1) 順時針旋轉 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]
                  

                  關于這個函數的三個注意事項:

                  Three notes about this function:

                  1. 對于順時針旋轉,最后一個參數angle應該是正數.對于逆時針旋轉(如您提供的圖表),它應該是負數.

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

                  請注意,即使您提供的參數應該產生一個坐標是整數的點——即將點 (5, 0) 圍繞原點 (0, 0) 旋轉 90 度,這應該產生 (0, -5) -- JavaScript 的舍入行為意味著任何一個坐標仍然可能是一個非常接近預期整數的值,但仍然是一個浮點數.例如:

                  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]
                  

                  因此,結果數組的兩個元素都應該是浮點數.您可以根據需要使用 Math.round()Math.ceil()Math.floor() 將它們轉換為整數.

                  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.

                  最后,請注意,此函數假定 笛卡爾坐標系,這意味著值當您在坐標平面中向上"時,Y 軸上的值會變得更高.在 HTML/CSS 中,Y 軸是倒置的——當您將頁面向下移動時,Y 軸上的值會變高.

                  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.

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

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

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  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 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  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="ohzjbob" id='Cw77v'><tfoot id='Cw77v'></tfoot><dl id='Cw77v'><fieldset id='Cw77v'></fieldset></dl></div>

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

                            主站蜘蛛池模板: 土壤水分自动监测站-SM150便携式土壤水分仪-铭奥仪器 | 发光字|标识设计|标牌制作|精神堡垒 - 江苏苏通广告有限公司 | uv机-uv灯-uvled光固化机-生产厂家-蓝盾机电 | 杭州用友|用友软件|用友财务软件|用友ERP系统--杭州协友软件官网 | 北京百度网站优化|北京网站建设公司-百谷网络科技 | 粘度计维修,在线粘度计,二手博勒飞粘度计维修|收购-天津市祥睿科技有限公司 | 铝板冲孔网,不锈钢冲孔网,圆孔冲孔网板,鳄鱼嘴-鱼眼防滑板,盾构走道板-江拓数控冲孔网厂-河北江拓丝网有限公司 | 日本东丽膜_反渗透膜_RO膜价格_超滤膜_纳滤膜-北京东丽阳光官网 日本细胞免疫疗法_肿瘤免疫治疗_NK细胞疗法 - 免疫密码 | 江门流水线|江门工作台|江门市伟涛行工业设备有限公司 | 诗词大全-古诗名句 - 古诗词赏析 | 艾默生变频器,艾默生ct,变频器,ct驱动器,广州艾默生变频器,供水专用变频器,风机变频器,电梯变频器,艾默生变频器代理-广州市盟雄贸易有限公司官方网站-艾默生变频器应用解决方案服务商 | led全彩屏-室内|学校|展厅|p3|户外|会议室|圆柱|p2.5LED显示屏-LED显示屏价格-LED互动地砖屏_蕙宇屏科技 | 上海公司注册-代理记账-招投标审计-上海昆仑扇财税咨询有限公司 上海冠顶工业设备有限公司-隧道炉,烘箱,UV固化机,涂装设备,高温炉,工业机器人生产厂家 | 奇酷教育-Python培训|UI培训|WEB大前端培训|Unity3D培训|HTML5培训|人工智能培训|JAVA开发的教育品牌 | 北京开业庆典策划-年会活动策划公司-舞龙舞狮团大鼓表演-北京盛乾龙狮鼓乐礼仪庆典策划公司 | 真空搅拌机-行星搅拌机-双行星动力混合机-广州市番禺区源创化工设备厂 | 手持气象站_便携式气象站_农业气象站_负氧离子监测站-山东万象环境 | 企典软件一站式企业管理平台,可私有、本地化部署!在线CRM客户关系管理系统|移动办公OA管理系统|HR人事管理系统|人力 | 液氨泵,液化气泵-淄博「亚泰」燃气设备制造有限公司 | 立式壁挂广告机厂家-红外电容触摸一体机价格-华邦瀛 | 氢氧化钙设备, 氢氧化钙生产线-淄博惠琛工贸有限公司 | 上海噪音治理公司-专业隔音降噪公司-中广通环保| 大行程影像测量仪-探针型影像测量仪-增强型影像测量仪|首丰百科 大通天成企业资质代办_承装修试电力设施许可证_增值电信业务经营许可证_无人机运营合格证_广播电视节目制作许可证 | 实战IT培训机构_IT培训班选大学生IT技术培训中心_中公优就业 | 手持式浮游菌采样器-全排二级生物安全柜-浙江孚夏医疗科技有限公司 | 砂石生产线_石料生产线设备_制砂生产线设备价格_生产厂家-河南中誉鼎力智能装备有限公司 | 【铜排折弯机,钢丝折弯成型机,汽车发泡钢丝折弯机,线材折弯机厂家,线材成型机,铁线折弯机】贝朗折弯机厂家_东莞市贝朗自动化设备有限公司 | 经济师考试_2025中级经济师报名时间_报名入口_考试时间_华课网校经济师培训网站 | 冷凝锅炉_燃气锅炉_工业燃气锅炉改造厂家-北京科诺锅炉 | 电动卫生级调节阀,电动防爆球阀,电动软密封蝶阀,气动高压球阀,气动对夹蝶阀,气动V型调节球阀-上海川沪阀门有限公司 | pH污水传感器电极,溶解氧电极传感器-上海科蓝仪表科技有限公司 | 披萨石_披萨盘_电器家电隔热绵加工定制_佛山市南海区西樵南方综合保温材料厂 | 内六角扳手「厂家」-温州市威豪五金工具有限公司 | 拼装地板,悬浮地板厂家,悬浮式拼装运动地板-石家庄博超地板科技有限公司 | 番茄畅听邀请码怎么输入 - Dianw8.com| 金属波纹补偿器厂家_不锈钢膨胀节价格_非金属伸缩节定制-庆达补偿器 | 全自动定氮仪-半自动凯氏定氮仪厂家-祎鸿仪器 | 深圳高新投三江工业消防解决方案提供厂家_服务商_园区智慧消防_储能消防解决方案服务商_高新投三江 | 微量水分测定仪_厂家_卡尔费休微量水分测定仪-淄博库仑 | MES系统工业智能终端_生产管理看板/安灯/ESOP/静电监控_讯鹏科技 | 大型工业风扇_工业大风扇_大吊扇_厂房车间降温-合昌大风扇 |