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

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

      <tfoot id='GNqAP'></tfoot>
      • <bdo id='GNqAP'></bdo><ul id='GNqAP'></ul>
      1. c# - 如何将点移动给定距离d(并获得新坐标)

        c# - how to move point a given distance d (and get a new coordinates)(c# - 如何将点移动给定距离d(并获得新坐标))

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

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

                • 本文介绍了c# - 如何将点移动给定距离d(并获得新坐标)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  嗨我想知道是否有任何有效的方法来计算点的坐标(从原始位置移动距离 d).

                  Hi I was wondering if there is any efficent way to calculating coordinates of point (which was moved distance d from it's original location).

                  假设我有一个点 P(0.3,0.5),我需要以距离 d 随机移动该点.

                  Let's say I have a point P(0.3,0.5) and I need to move that point random direction with distance d.

                  到目前为止,我通过随机选择新的 x 和 y 坐标来做到这一点,并且我正在检查新旧点之间的距离是否等于 d.我确实意识到这样做不是太有效的方法.你会怎么做??

                  So far I did it by random picking new x and y coordinates and I was checking if distance between old and new point equals d. I do realize that is't too eficient way to do that. How would You do it ??

                  推荐答案

                  给定一个点(x1, y1),我们想找一个随机"点(x2, y2) 距离它 d.

                  Given a point (x1, y1), we want to find a "random" point (x2, y2) at a distance d from it.

                  选择一个随机角度theta.那么:

                  Pick a random angle theta. Then:

                  x2 = x1 + d * cos(theta)
                  y2 = y1 + d * sin(theta)
                  

                  这将是半径为 d 的圆上的一个随机点,该圆以 (x1, y1)

                  This will be a random point on a circle of radius d centered at (x1, y1)

                  证明:

                  Distance between (x1, y1) and (x2, y2)
                  = sqrt ( (x2 - x1) ^ 2 + (y2 - y1) ^ 2)
                  = sqrt ( d^2 * (sin^2 (theta) + cos^2 (theta) ) )
                  = d
                  

                  你可能想看看:

                  • 极坐标系
                  • 距离公式
                  • 毕达哥拉斯三角恒等式

                  这篇关于c# - 如何将点移动给定距离d(并获得新坐标)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                  Accessing attribute info from DTE(从 DTE 访问属性信息)
                  c# Hide a property in datagridview with datasource(c#使用数据源隐藏datagridview中的属性)
                  Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                  C# Attributes and their uses(C# 属性及其用途)
                  C# - Getting all enums value by attribute(C# - 按属性获取所有枚举值)
                • <small id='xMp6i'></small><noframes id='xMp6i'>

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

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