中点画椭圆算法_中点圆算法

本文详细介绍了中点圆算法,这是一种用于计算圆周上点的算法,尤其适用于第一象限,因为圆的对称性。算法基于决策参数,根据圆的方程判断点是否在圆内、圆上或圆外。通过不断调整决策参数,可以得到圆周上的点,并通过中心对称获取其他象限的点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

中点画椭圆算法

中点圆算法 (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.

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

Midpoint circle algo

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

中点画椭圆算法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值