中点画椭圆算法

中点圆算法 (Midpoint circle Algorithm)

This is an algorithm which is used to calculate the entire perimeter points of a circle in a first octant so that the points of the other octant can be taken easily as they are mirror points; this is due to circle property as it is symmetric about its center.

这是一种算法,用于计算第一个八分圆中一个圆的整个周边点,以便可以轻松地将另一个八分圆的点视为镜像点; 这是由于圆的属性有关它的中心对称。

In this algorithm decision parameter is based on a circle equation. As we know that the equation of a circle is x2 +y2 =r2 when the centre is (0, 0).

在该算法中,决策参数基于圆方程。 众所周知,当中心为(0,0)时,圆的方程为x 2 + y 2 = r 2

Now let us define the function of a circle i.e.: fcircle(x,y)= x2 +y2 - r2

现在让我们定义一个圆的函数,即: fcircle(x,y)= x 2 + y 2 -r 2

  1. If fcircle < 0 then x, y is inside the circle boundary.

    如果fcircle <0,xy在圆边界之内。

  2. If fcircle > 0 then x, y is outside the circle boundary.

    如果fcircle> 0,xy在圆边界之外。

  3. If fcircle = 0 then x, y is on the circle boundary.

    如果fcircle = 0,xy在圆边界上。

决策参数 (Decision parameter)

pk =fcircle(xk+1,yk-1/2) where pk is a decision parameter and in this ½ is taken because it is a midpoint value through which it is easy to calculate value of yk and yk-1.

p k = fcircle(x k + 1 ,y k-1 / 2 ) ,其中p k是决策参数,在此1/2中采用p k是因为它是一个中点值,通过该中点值很容易计算y ky k -1

I.e. pk= (xk+1)2+ (yk-1/2)2-r2

p k =(x k + 1 ) 2 +(y k-1 / 2 ) 2 -r 2

If pk <0 then midpoint is inside the circle in this condition we select y is yk otherwise we will select next y as yk-1 for the condition of pk > 0.

如果p k <0,则在这种情况下中点在圆内,我们选择yy k,否则对于p k > 0的情况,我们将下一个y选择为y k-1

结论 (Conclusion)

  1. If pk < 0 then yk+1=yk, by this the plotting points will be ( xk+1 ,yk). By this the value for the next point will be given as:

    如果p k <0,y k + 1 = y k ,由此绘制点将为(x k + 1 ,y k ) 。 这样,下一点的值将为:

    Pk+1=pk +2(xk+1) +1

    P k + 1 = p k +2(x k + 1 )+1

  2. If pk > 0 then yk+1=yk-1, by this the plotting points will be (xk+1, yk-1). By this the value of the next point will be given as:

    如果p k > 0,y k + 1 = y k-1 ,由此绘制点将为(x k + 1 ,y k-1 ) 。 这样,下一点的值将为:

    Pk+1=pk+2(xk+1) +1-2(yk+1)

    P k + 1 = p k +2(x k + 1 )+ 1-2(y k + 1 )

初始决策参数 (Initial decision parameter)

P0 = fcircle (1, r-1/2)

P 0 =圆(1,r-1 / 2)

This is taken because of (x0, y0) = (0, r)

这是因为(x 0 ,y 0 )=(0,r)

i.e. p0 =5/4-r or 1-r, (1-r will be taken if r is integer)

p 0 = 5 / 4-r或1-r ,(如果r为整数则采用1-r )

算法 (ALGORITHM)

  1. In this the input radius r is there with a centre (xc , yc). To obtain the first point m the circumference of a circle is centered on the origin as (x0,y0) = (0,r).

    在此,输入半径r以一个中心(x c ,y c )为中心。 为了获得第一个点m ,圆的圆周以(x 0 ,y 0 )=(0,r)为中心

  2. Calculate the initial decision parameters which are:

    计算初始决策参数为:

    p0 =5/4-r or 1-r

    p 0 = 5 / 4-r或1-r

  3. Now at each xk position starting k=0, perform the following task.

    现在,在从k = 0开始的每个x k位置,执行以下任务。

    if

    如果

    pk < 0 then plotting point will be ( xk+1 ,yk) and

    p k <0,则绘图点将为(x k + 1 ,y k )并且

    Pk+1=pk +2(xk+1) +1

    P k + 1 = p k +2(x k + 1 )+1

    else the next point along the circle is (x

    否则沿圆的下一个点是[x

    k+1, yk-1) and

    k + 1 ,y k-1 )和

    Pk+1=pk+2(xk+1) +1-2(yk+1)

    P k + 1 = p k +2(x k + 1 )+ 1-2(y k + 1 )

  4. Determine the symmetry points in the other quadrants.

    确定其他象限中的对称点。

  5. Now move at each point by the given centre that is:

    现在按照给定的中心在每个点处移动:

    x=x+xc

    x = x + x c

    y=y+yc

    y = y + y c

  6. At last repeat steps from 3 to 5 until the condition x>=y.

    最后重复步骤3到5,直到条件x> = y为止。

翻译自: https://www.includehelp.com/algorithms/midpoint-circle.aspx

中点画椭圆算法

中点画椭圆算法_中点圆算法相关推荐

  1. 【寒江雪】中点画椭圆算法

    中点画椭圆算法与中点画圆算法非常类似 但是其中有区别的地方就是,椭圆不是八对称的.不能像圆那样扫描八分之一就可以绘制出整个圆.所以,必须要考虑在扫描四分之一椭圆的过程中,遇到斜率为-1的切线. 如下图 ...

  2. 【Matlab】智能优化算法_蜻蜓优化算法DA

    [Matlab]智能优化算法_蜻蜓优化算法DA 1.背景介绍 2.灵感 3.公式推导 3.1 勘探和开发操作 4.算法流程图 5.文件结构 6.伪代码 7.详细代码及注释 7.1 DA.m 7.2 d ...

  3. 【Matlab】智能优化算法_蚁狮优化算法ALO

    [Matlab]智能优化算法_蚁狮优化算法ALO 1.背景介绍 2.基本思想 3.公式推导 3.1 ALO算法的运算符 3.2 蚂蚁的随机游动 3.3 困在蚂蚁坑里 3.4 修建陷阱 3.5 蚂蚁划向 ...

  4. 【Matlab】智能优化算法_灰狼优化算法GWO

    [Matlab]智能优化算法_灰狼优化算法GWO 1.背景介绍 2.基本思想 2.1 等级制度 2.2 狩猎方式 3.公式推导 3.1 社会等级制度 3.2 包围猎物 3.3 包围猎物 3.4 攻击猎 ...

  5. dbscan算法中 参数的意义_常用聚类算法

    一.K-Means 算法步骤: (1) 首先我们选择一些类/组,并随机初始化它们各自的中心点.中心点是与每个数据点向量长度相同的位置.这需要我们提前预知类的数量(即中心点的数量). (2) 计算每个数 ...

  6. 图形学--(中点画线法+Bresenham画线算法)

    编程环境:codeblocks+EGE库 用到的函数:putpixel(int x1,int y1,int color)  用某种颜色打亮一个坐标点. 这俩种算法都是用来在计算机上画一条直线的,那么我 ...

  7. python实现洗牌算法_洗牌算法及 random 中 shuffle 方法和 sample 方法浅析

    对于算法书买了一本又一本却没一本读完超过 10%,Leetcode 刷题从来没坚持超过 3 天的我来说,算法能力真的是渣渣.但是,今天决定写一篇跟算法有关的文章.起因是读了吴师兄的文章 <扫雷与 ...

  8. dqn在训练过程中loss越来越大_用DQN算法玩FlappyBird

    DQN算法可以用于解决离散的动作问题,而FlappyBird的操作正好是离散的. FlappyBird的游戏状态一般可以通过图像加卷积神经网络(CNN)来进行强化学习.但是通过图像分析会比较麻烦,因为 ...

  9. 图形学---中点画线法---opengl中实现

    目的: 为了优化DDA算法中的浮点数运算(DDA中每次+k运算,|k|<1,所以存在浮点数运算),达到整数运算,提高效率. 基本思想: 当前像素点为(xp,yp),下一像素点为P1或P2.设P1 ...

最新文章

  1. IOS开发 使用CGContextRef绘制文字时的设置
  2. AngularJS转换请求内容
  3. IEA:截止2015年全球太阳能光伏装机累计超228GW
  4. mysql查询结果单位换算后小数位数的保留方式
  5. C++Study 指针详解
  6. MongoDB入门简单介绍
  7. 网络暴力信号:你家的青少年是受害者或加害者吗?
  8. 足球赛事分组代码PHP,PHP数组分组排序程序代码
  9. python求解微分方程组_python – SymPy / SciPy:求解具有不同变量的常微分方程组...
  10. mime类型是什么 node_Node.js - 文件系统获取文件类型
  11. 素数方法(thinking in java)
  12. HTML 中多媒体设置:1、滚动字幕及滚动图片的设置 2、音乐视频的插入
  13. 51nod 1412
  14. 计算机专业英语第五章ppt,计算机专业英语课件5.ppt
  15. wsdl2java工具生成客户端代码
  16. SpringBoot学习---页面国际化
  17. PDM系统的结构设计
  18. 慧荣SM2258XT-主板CE跳线Toggle土狗跳线合集整理(持续更新)
  19. 机械电钢琴音源 Cinesamples Keyboard In Blue Kontakt
  20. python三国演义人物出场统计txt文本_python实例:三国演义TXT文本词频分析

热门文章

  1. 今天不聊技术,聊聊如何成为一个靠谱的软件从业人员
  2. Springboot+vue 增删改查的小项目
  3. java i18n utf_Java国际化(i18n)字符串与Unicode转换
  4. 【Chrome-Charset】Chrome设置字符集
  5. QT-Linux安装
  6. DataFrame按某种指定顺序排序
  7. 30M DEM数据处理成图
  8. 为什么我不再运营百家号了?这说出了我的心声
  9. 为什么百度搜索引擎优化比以前更难?
  10. 流上机器学习,星环科技Sophon Base助力海洋石油富岛工艺监测智能化