久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

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

      1. 畫一個圓的半徑和點周圍的邊緣

        Draw a circle with a radius and points around the edge(畫一個圓的半徑和點周圍的邊緣)
        <legend id='cfxVJ'><style id='cfxVJ'><dir id='cfxVJ'><q id='cfxVJ'></q></dir></style></legend>

          <tfoot id='cfxVJ'></tfoot>

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

              • <bdo id='cfxVJ'></bdo><ul id='cfxVJ'></ul>
                  <tbody id='cfxVJ'></tbody>
                  <i id='cfxVJ'><tr id='cfxVJ'><dt id='cfxVJ'><q id='cfxVJ'><span id='cfxVJ'><b id='cfxVJ'><form id='cfxVJ'><ins id='cfxVJ'></ins><ul id='cfxVJ'></ul><sub id='cfxVJ'></sub></form><legend id='cfxVJ'></legend><bdo id='cfxVJ'><pre id='cfxVJ'><center id='cfxVJ'></center></pre></bdo></b><th id='cfxVJ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cfxVJ'><tfoot id='cfxVJ'></tfoot><dl id='cfxVJ'><fieldset id='cfxVJ'></fieldset></dl></div>
                  本文介紹了畫一個圓的半徑和點周圍的邊緣的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我真的被困在如何進行編程上.如何在Java中繪制一個半徑和邊緣周圍的圓?

                  I'm really stuck on how to go about programming this. How to draw a circle in Java with a radius and points around the edge?

                  我需要在 JFrame 內繪制一個圓,其半徑和點圍繞圓周.我可以數學計算如何找到邊緣周圍點的坐標,但我似乎無法對圓進行編程.我目前正在使用 Ellipse2D 方法,但這似乎不起作用并且不返回半徑,據我了解,它不會從中心繪制圓,而是使用高度和寬度從起始坐標繪制圓.

                  I need to draw a circle within a JFrame with a radius and points around the circumference. i can mathematically calculate how to find the coordinates of the point around the edge but i cant seem to be able to program the circle. I am currently using a Ellipse2D method but that doesn't seem to work and doesn't return a radius, as under my understanding, it doesn't draw the circle from the center rather from a starting coordinate using a height and width.

                  我當前的代碼在一個單獨的框架上,但我需要將它添加到我現有的框架中.

                  My current code is on a separate frame but I need to add it to my existing frame.

                  import java.awt.*; 
                  import javax.swing.*; 
                  import java.awt.geom.*; 
                  
                  public class circle extends JFrame { 
                    public circle() { 
                       super("circle"); 
                       setSize(410, 435); 
                       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
                       Panel sp = new Panel(); 
                       Container content = getContentPane(); 
                       content.add(sp); 
                       setContentPane(content); 
                       setVisible(true); 
                   } 
                  
                   public static void main (String args[]){
                    circle sign = new circle(); 
                   } 
                  } 
                  
                  class Panel extends JPanel { 
                   public void paintComponent(Graphics comp) { 
                       super.paintComponent(comp); 
                       Graphics2D comp2D = (Graphics2D) comp; 
                  
                       comp2D.setColor(Color.red); 
                       Ellipse2D.Float sign1 = new Ellipse2D.Float(0F, 0F, 350F, 350F); 
                       comp2D.fill(sign1); 
                   } 
                  }
                  

                  推薦答案

                  circle 上的點 可以指定為角度 θ 的函數:

                  Points on a circle may be specified as a function of the angle θ:

                  x = a + r cos(θ)
                  y = b + r sin(θ)

                  這里顯示了2π/8的增量.

                  附錄:正如 @Christoffer Hammarstr?m 的評論中所建議的,這個 修訂 示例減少了 magic numbers 原文.所需的點數成為構造函數的參數.它還使渲染適應容器的大小.

                  Addendum: As suggested in a comment by @Christoffer Hammarstr?m, this revised example reduces the number of magic numbers in the original. The desired number of points becomes a parameter to the constructor. It also adapts the rendering to the container's size.

                  /** @see https://stackoverflow.com/questions/2508704 */
                  public class CircleTest extends JPanel {
                  
                      private static final int SIZE = 256;
                      private int a = SIZE / 2;
                      private int b = a;
                      private int r = 4 * SIZE / 5;
                      private int n;
                  
                      /** @param n  the desired number of circles. */
                      public CircleTest(int n) {
                          super(true);
                          this.setPreferredSize(new Dimension(SIZE, SIZE));
                          this.n = n;
                      }
                  
                      @Override
                      protected void paintComponent(Graphics g) {
                          super.paintComponent(g);
                          Graphics2D g2d = (Graphics2D) g;
                          g2d.setRenderingHint(
                              RenderingHints.KEY_ANTIALIASING,
                              RenderingHints.VALUE_ANTIALIAS_ON);
                          g2d.setColor(Color.black);
                          a = getWidth() / 2;
                          b = getHeight() / 2;
                          int m = Math.min(a, b);
                          r = 4 * m / 5;
                          int r2 = Math.abs(m - r) / 2;
                          g2d.drawOval(a - r, b - r, 2 * r, 2 * r);
                          g2d.setColor(Color.blue);
                          for (int i = 0; i < n; i++) {
                              double t = 2 * Math.PI * i / n;
                              int x = (int) Math.round(a + r * Math.cos(t));
                              int y = (int) Math.round(b + r * Math.sin(t));
                              g2d.fillOval(x - r2, y - r2, 2 * r2, 2 * r2);
                          }
                      }
                  
                      private static void create() {
                          JFrame f = new JFrame();
                          f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                          f.add(new CircleTest(9));
                          f.pack();
                          f.setVisible(true);
                      }
                  
                      public static void main(String[] args) {
                          EventQueue.invokeLater(new Runnable() {
                  
                              @Override
                              public void run() {
                                  create();
                              }
                          });
                      }
                  }
                  

                  這篇關于畫一個圓的半徑和點周圍的邊緣的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                • <i id='GP2Nm'><tr id='GP2Nm'><dt id='GP2Nm'><q id='GP2Nm'><span id='GP2Nm'><b id='GP2Nm'><form id='GP2Nm'><ins id='GP2Nm'></ins><ul id='GP2Nm'></ul><sub id='GP2Nm'></sub></form><legend id='GP2Nm'></legend><bdo id='GP2Nm'><pre id='GP2Nm'><center id='GP2Nm'></center></pre></bdo></b><th id='GP2Nm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GP2Nm'><tfoot id='GP2Nm'></tfoot><dl id='GP2Nm'><fieldset id='GP2Nm'></fieldset></dl></div>

                  <tfoot id='GP2Nm'></tfoot>

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

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

                        1. <legend id='GP2Nm'><style id='GP2Nm'><dir id='GP2Nm'><q id='GP2Nm'></q></dir></style></legend>

                            <tbody id='GP2Nm'></tbody>

                            主站蜘蛛池模板: 黄毛片 | 在线黄av | 国产精品毛片无码 | 亚洲精品一区二区另类图片 | 日本不卡一区 | av黄色在线观看 | 日韩中文字幕免费在线 | 日韩在线小视频 | 亚洲高清在线观看 | 亚洲精品久久久一区二区三区 | 亚洲国产精品99久久久久久久久 | 日本黄色免费视频 | 国产精品永久免费观看 | 91视频.com | www国产成人免费观看视频,深夜成人网 | 视频一区二区中文字幕 | 国产精品一区二区在线 | 亚洲精品成人网 | 国产激情视频在线免费观看 | 在线视频国产一区 | 午夜视频一区二区三区 | 国产自产21区| 涩色视频在线观看 | 成人视屏在线观看 | 亚洲国产一区二区三区四区 | 亚洲精品一区二区三区 | 成人欧美一区二区三区 | 亚洲一区 中文字幕 | 综合第一页 | 狠狠爱视频 | 九色网址 | 欧美性一区二区三区 | 少妇特黄a一区二区三区88av | 日韩av一二三区 | 欧美成人精品 | 精久久久| 精品久久香蕉国产线看观看亚洲 | 在线一区 | 丝袜 亚洲 欧美 日韩 综合 | 久久精品国产久精国产 | 欧美一级二级三级视频 |