<legend id='nTFbJ'><style id='nTFbJ'><dir id='nTFbJ'><q id='nTFbJ'></q></dir></style></legend>
    • <bdo id='nTFbJ'></bdo><ul id='nTFbJ'></ul>

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

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

      1. 围绕其中心点/轴旋转 3D 形状

        Rotate 3D shape around its centeroid/axis(围绕其中心点/轴旋转 3D 形状)
          <tbody id='wqsAO'></tbody>
          • <bdo id='wqsAO'></bdo><ul id='wqsAO'></ul>

            <i id='wqsAO'><tr id='wqsAO'><dt id='wqsAO'><q id='wqsAO'><span id='wqsAO'><b id='wqsAO'><form id='wqsAO'><ins id='wqsAO'></ins><ul id='wqsAO'></ul><sub id='wqsAO'></sub></form><legend id='wqsAO'></legend><bdo id='wqsAO'><pre id='wqsAO'><center id='wqsAO'></center></pre></bdo></b><th id='wqsAO'></th></span></q></dt></tr></i><div id='wqsAO'><tfoot id='wqsAO'></tfoot><dl id='wqsAO'><fieldset id='wqsAO'></fieldset></dl></div>
          • <tfoot id='wqsAO'></tfoot>

                • <legend id='wqsAO'><style id='wqsAO'><dir id='wqsAO'><q id='wqsAO'></q></dir></style></legend>

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

                  本文介绍了围绕其中心点/轴旋转 3D 形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 STL 文件中定义了一个 3D 形状,我想使用 Yaw、Pitch 和 Roll 围绕它的轴/中心旋转它.但是,我已经实现了一个解决方案,但它并没有按预期工作,因为 它会围绕原点轴旋转 3D 形状.这是我到目前为止所做的(用 PHP 编写):

                  I have a 3D shape defined in STL file and I'd like to rotate it around its axis/center using Yaw, Pitch and Roll. However, I've already implemented a solution and it doesn't work as expected as it rotates the 3D shape around the origin axis instead. Here's what I've done so far (written in PHP):

                  function rotate($vertices, $roll = 0, $pitch = 0, $yaw = 0) 
                  {
                      if(!empty($vertices))
                      {
                          $cosa = cos($yaw);
                          $sina = sin($yaw);
                  
                          $cosb = cos($pitch);
                          $sinb = sin($pitch);
                  
                          $cosc = cos($roll);
                          $sinc = sin($roll);
                  
                          $Axx = $cosa * $cosb;
                          $Axy = $cosa * $sinb * $sinc - $sina * $cosc;
                          $Axz = $cosa * $sinb * $cosc + $sina * $sinc;
                  
                          $Ayx = $sina * $cosb;
                          $Ayy = $sina * $sinb * $sinc + $cosa * $cosc;
                          $Ayz = $sina * $sinb * $cosc - $cosa * $sinc;
                  
                          $Azx = -$sinb;
                          $Azy = $cosb * $sinc;
                          $Azz = $cosb * $cosc;
                  
                          //loop through all triangles
                          foreach($vertices as $i => $vertex) 
                          {
                              $px = $vertex->x;
                              $py = $vertex->y;
                              $pz = $vertex->z;
                  
                              $points = 
                              [
                                  'x' => ($Axx * $px + $Axy * $py + $Axz * $pz), 
                                  'y' => ($Ayx * $px + $Ayy * $py + $Ayz * $pz), 
                                  'z' => ($Azx * $px + $Azy * $py + $Azz * $pz)
                              ];
                  
                              //update the vertex
                              $vertices[$i]->setVertex($vi, $points);
                          }
                      }
                  
                      return $vertices;
                  }
                  

                  如果我遗漏了什么,请告诉我.任何帮助将不胜感激.

                  Please let me know if I'm missing something. any help would be appreciated.

                  推荐答案

                  上面的代码绕原点旋转.如果您的旋转中心(例如 $c)不是原点,您可以在旋转之前移动对象:

                  The code above rotates about the origin. If your centre of rotation (say, $c), isn't the origin, you can move the object before rotating:

                  $px = $vertex->x - $c->x;
                  $py = $vertex->y - $c->y;
                  $pz = $vertex->z - $c->z;
                  

                  旋转后,将点移回旋转中心:

                  After rotating, move the point back to the centre of rotation:

                  $points = 
                  [
                      'x' => ($Axx * $px + $Axy * $py + $Axz * $pz) + $c->x, 
                      'y' => ($Ayx * $px + $Ayy * $py + $Ayz * $pz) + $c->y, 
                      'z' => ($Azx * $px + $Azy * $py + $Azz * $pz) + $c->z
                  ];
                  

                  这篇关于围绕其中心点/轴旋转 3D 形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                • <small id='fC2Qv'></small><noframes id='fC2Qv'>

                    <tbody id='fC2Qv'></tbody>

                • <i id='fC2Qv'><tr id='fC2Qv'><dt id='fC2Qv'><q id='fC2Qv'><span id='fC2Qv'><b id='fC2Qv'><form id='fC2Qv'><ins id='fC2Qv'></ins><ul id='fC2Qv'></ul><sub id='fC2Qv'></sub></form><legend id='fC2Qv'></legend><bdo id='fC2Qv'><pre id='fC2Qv'><center id='fC2Qv'></center></pre></bdo></b><th id='fC2Qv'></th></span></q></dt></tr></i><div id='fC2Qv'><tfoot id='fC2Qv'></tfoot><dl id='fC2Qv'><fieldset id='fC2Qv'></fieldset></dl></div>

                      • <bdo id='fC2Qv'></bdo><ul id='fC2Qv'></ul>
                        • <tfoot id='fC2Qv'></tfoot>
                          <legend id='fC2Qv'><style id='fC2Qv'><dir id='fC2Qv'><q id='fC2Qv'></q></dir></style></legend>