<legend id='kdNW4'><style id='kdNW4'><dir id='kdNW4'><q id='kdNW4'></q></dir></style></legend>

    1. <tfoot id='kdNW4'></tfoot>
    2. <small id='kdNW4'></small><noframes id='kdNW4'>

          <bdo id='kdNW4'></bdo><ul id='kdNW4'></ul>

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

        在 0 到 360 之间标准化方向

        Normalise orientation between 0 and 360(在 0 到 360 之间标准化方向)

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

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

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

                  <tbody id='iubJe'></tbody>
              • <tfoot id='iubJe'></tfoot>
                1. 本文介绍了在 0 到 360 之间标准化方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在研究一个简单的旋转例程,它将对象旋转规范化在 0 到 360 度之间.我的 C# 代码似乎可以工作,但我对它并不完全满意.任何人都可以改进下面的代码使其更加健壮吗?

                  I'm working on a simple rotate routine which normalizes an objects rotation between 0 and 360 degrees. My C# code seems to be working but I'm not entirely happy with it. Can anyone improve on the code below making it a bit more robust?

                  public void Rotate(int degrees)
                      {
                          this.orientation += degrees;
                  
                          if (this.orientation < 0)
                          {
                              while (this.orientation < 0)
                              {
                                  this.orientation += 360;
                              }
                          }
                          else if (this.orientation >= 360)
                          {
                              while (this.orientation >= 360)
                              {
                                  this.orientation -= 360;
                              }
                          }
                      }
                  

                  推荐答案

                  使用模运算:

                  this.orientation += degrees;
                  
                  this.orientation = this.orientation % 360;
                  
                  if (this.orientation < 0)
                  {
                      this.orientation += 360;
                  }
                  

                  这篇关于在 0 到 360 之间标准化方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

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

                        <tfoot id='af0pK'></tfoot>

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

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