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

    2. <legend id='ii1DT'><style id='ii1DT'><dir id='ii1DT'><q id='ii1DT'></q></dir></style></legend>

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

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

        计算正多边形顶点的坐标

        时间:2023-07-25

        1. <tfoot id='mBZ0C'></tfoot>
              <tbody id='mBZ0C'></tbody>

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

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

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

                • 本文介绍了计算正多边形顶点的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在编写一个程序,在该程序中我需要绘制任意数量的边的多边形,每个边都由一个动态变化的给定公式转换.涉及一些相当有趣的数学,但我被困在这个问题上.

                  I am writing a program in which I need to draw polygons of an arbitrary number of sides, each one being translated by a given formula which changes dynamically. There is some rather interesting mathematics involved but I am stuck on this probelm.

                  如何计算正多边形(所有角度都相等)的顶点坐标,仅给出边数,理想情况下(但不是必须)具有原点在中心?

                  How can I calculate the coordinates of the vertices of a regular polygon (one in which all angles are equal), given only the number of sides, and ideally (but not neccessarily) having the origin at the centre?

                  例如:一个六边形可能有以下几点(都是floats):

                  For example: a hexagon might have the following points (all are floats):

                  ( 1.5  ,  0.5 *Math.Sqrt(3) )
                  ( 0    ,  1   *Math.Sqrt(3) )
                  (-1.5  ,  0.5 *Math.Sqrt(3) )
                  (-1.5  , -0.5 *Math.Sqrt(3) )
                  ( 0    , -1   *Math.Sqrt(3) )
                  ( 1.5  , -0.5 *Math.Sqrt(3) )
                  

                  我的方法是这样的:

                  void InitPolygonVertexCoords(RegularPolygon poly)
                  

                  并且需要将坐标添加到此(或类似的东西,如列表):

                  and the coordinates need to be added to this (or something similar, like a list):

                  Point[] _polygonVertexPoints;
                  

                  我主要对这里的算法感兴趣,但 C# 中的示例会很有用.我什至不知道从哪里开始.我应该如何实现它?有可能吗?!

                  I'm interested mainly in the algorithm here but examples in C# would be useful. I don't even know where to start. How should I implement it? Is it even possible?!

                  谢谢.

                  推荐答案

                  for (i = 0; i < n; i++) {
                    printf("%f %f
                  ",r * Math.cos(2 * Math.PI * i / n), r * Math.sin(2 * Math.PI * i / n));
                  }
                  

                  其中 r 是外接圆的半径.对不起,错误的语言没有 Habla C#.

                  where r is the radius of the circumsribing circle. Sorry for the wrong language No Habla C#.

                  基本上任意两个顶点之间的夹角是2 pi/n,并且所有顶点距离原点r.

                  Basically the angle between any two vertices is 2 pi / n and all the vertices are at distance r from the origin.

                  如果你想让中心在原点以外的地方,比如 (x,y)

                  If you want to have the center somewher other than the origin, say at (x,y)

                  for (i = 0; i < n; i++) {
                    printf("%f %f
                  ",x + r * Math.cos(2 * Math.PI * i / n), y + r * Math.sin(2 * Math.PI * i / n));
                  }
                  

                  这篇关于计算正多边形顶点的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:检测两个重合线段的重合子集 下一篇:如何在 C、C#/.NET 2.0 或 Java 的所有情况下计算点和线段之间的最短 2D 距离?

                  相关文章

                  <tfoot id='kfNaV'></tfoot>

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

                    1. <small id='kfNaV'></small><noframes id='kfNaV'>