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

    1. <tfoot id='E45u7'></tfoot>

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

        在C#中从角度计算圆周上的点?

        时间:2023-07-25

        <tfoot id='IOlce'></tfoot>

            • <bdo id='IOlce'></bdo><ul id='IOlce'></ul>
              • <small id='IOlce'></small><noframes id='IOlce'>

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

                  本文介绍了在C#中从角度计算圆周上的点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想这是一个简单的问题,但是我当前的代码得到了一些奇怪的结果,而且我没有数学背景来完全理解原因.正如标题中所述,我的目标很简单:我只想找到与中心点有一定距离和角度的点.

                  I imagine that this is a simple question, but I'm getting some strange results with my current code and I don't have the math background to fully understand why. My goal is simple, as stated in the title: I just want to find the point at some distance and angle from a center point.

                  我当前的代码:

                  Point centerPoint = new Point ( 0, 0 );
                  Point result      = new Point ( 0, 0 );
                  double angle      = 0.5; //between 0 and 2 * PI, angle is in radians
                  int distance      = 1000;
                  
                  result.Y = centerPoint.Y + (int)Math.Round( distance * Math.Sin( angle ) );
                  result.X = centerPoint.X + (int)Math.Round( distance * Math.Cos( angle ) );
                  

                  一般来说,这似乎工作得相当合理,但我在不同的地方遇到了问题,最明显的是当角度对应于负 x 和 y 轴上的点时.很明显我做错了什么——想想那是什么?

                  In general, this seems to work fairly reasonably, but I get problems at various spots, most notably when the angle corresponds to points in the negative x and y axis. Clearly I'm doing something wrong -- thoughts on what that is?

                  更新:这是我的错误,这段代码工作正常——少数不工作的异常值实际上是由于计算 1.5PI 的角度存在错误.我以为我已经检查得足够好,但显然没有.感谢大家的宝贵时间,希望上面的工作代码对其他人有帮助.

                  UPDATE: This was my mistake, this code works fine -- the few outliers that were not working were actually due to a bug in how the angle for 1.5PI was being calculated. I thought I had checked that well enough, but evidently had not. Thanks to everyone for their time, hopefully the working code above will prove helpful to someone else.

                  推荐答案

                  你忘了添加中心点:

                  result.Y = (int)Math.Round( centerPoint.Y + distance * Math.Sin( angle ) );
                  result.X = (int)Math.Round( centerPoint.X + distance * Math.Cos( angle ) );
                  

                  其余的应该没问题...(你得到了什么奇怪的结果?你能给出准确的输入吗?)

                  The rest should be ok... (what strange results were you getting? Can you give an exact input?)

                  这篇关于在C#中从角度计算圆周上的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:获得离线最近的点 下一篇:沿 A-B 线计算距 A 给定距离的点

                  相关文章

                    <bdo id='5QRoF'></bdo><ul id='5QRoF'></ul>

                  <small id='5QRoF'></small><noframes id='5QRoF'>

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