zoukankan      html  css  js  c++  java
  • 中点算法绘制椭圆_程序

    中点算法绘制椭圆_程序

    1. 中点算法绘制椭圆

      由于算法特殊性,程序限制绘制第一象限部分;

     1 void CCGProjectWorkView::midPoint_1P4Ellipse(int radiumA, int radiumB, const float lineColor[])
     2 {
     3     int pointX, pointY;
     4     float jugeFactorUp, jugeFactorDown;
     5     pointX = 0;
     6     pointY = radiumB;
     7 
     8     glColor3f(lineColor[0], lineColor[1], lineColor[2]);
     9     glBegin(GL_POINTS);
    10 
    11     jugeFactorUp = radiumB*radiumB + radiumA*radiumA*(-radiumB + 0.25);
    12     glVertex3f(pointX, pointY, 0);
    13     while (radiumB*radiumB*(pointX+1) < radiumA*radiumA*(pointY-0.5))
    14     {
    15         if (jugeFactorUp < 0)//中点在内部,正右方点H
    16         {
    17             jugeFactorUp += radiumB*radiumB*(2*pointX + 3);
    18             pointX++;
    19         }
    20         else
    21         {
    22             jugeFactorUp += (radiumB*radiumB*(2*pointX + 3) + radiumA*radiumA*(-2*pointY + 2));
    23             pointY--;
    24             pointX++;
    25         }
    26         glVertex3f(pointX, pointY, 0);
    27     }
    28     
    29     jugeFactorDown = sqrt(radiumB*(pointX + 0.5)) + radiumA*(pointY - 1) - radiumA*radiumB;
    30     while(pointY > 0)
    31     {
    32         if (jugeFactorDown < 0)//在圆内,取D
    33         {
    34             jugeFactorDown += radiumB*radiumB*(2*pointX + 2) + radiumA*radiumA*(-2*pointY + 3);
    35             pointX++;
    36             pointY--;
    37         }
    38         else
    39         {
    40             jugeFactorDown += radiumA*radiumA*(-2*pointY +3);
    41             pointY--;
    42         }
    43         glVertex3f(pointX, pointY, 0);
    44     }
    45     
    46     glEnd();
    47 
    48 }
  • 相关阅读:
    lamp架构之升级php版本
    Linux常用命令大全
    Mysql表连接查询
    PHP练习题三
    PHP练习题二
    php 设计模式
    LAMP环境搭建教程
    Storm入门(四)WordCount示例
    Storm入门(三)HelloWorld示例
    Storm入门(一)原理介绍
  • 原文地址:https://www.cnblogs.com/icmzn/p/5046690.html
Copyright © 2011-2022 走看看