Algorithm for generating a digital circle on a triangulargrid

  • Published on
    02-Jul-2016

  • View
    212

  • Download
    0

Transcript

<ul><li><p>COMPUTER ORA1)mcs AND ~tAOn PrtocEssn~o 15,401-402 (1981) </p><p>NOTE </p><p>Algorithm for Generating a Digital Circle on a Triangular Grid </p><p>KENSUKE SHIMIZU </p><p>Department of Computer Science, Gunma Utlioersily, Kiryu 376, Japan </p><p>Received March 12, 1980 </p><p>An algorithm for determining the node-to-node movements to generate a digital circle on a triangular grid is given. At each step, we choose the one of three directions which minimiTcs If(u, v)l wheref(u, v) ffi 0 is the circle equation. </p><p>I t was pointed out by Freeman [1] that the use of a hexagonal coordinate system is attractive for certain specialized applications because the distance to the six nodes surrounding a given node is unity and it permits rotation by any multiple of 60 ~ without recomputation of the plotting sequence. </p><p>We shall here derive an algorithm for determining the node-to-node movements to generate a digital circle on the triangular grid with (u, v) coordinate system shown in Fig. 1. The positive vaxis makes an angle of 120 ~ with the u axis. </p><p>On a Cartesian coordinate system, the equation for a circle centered at the origin with radius R is </p><p>f (x ,y ) ~ x 2 +y2 _ R 2 _ 0. </p><p>I f the u axis is consistent with the x axis, </p><p>(i) </p><p>x=u-v/2 y=V3v/2. </p><p>Substituting (2) into (1), we obtain </p><p>f (U ,V) ~t t 2 -- UV + V 2 - R 2 ffi 0. </p><p>(2) </p><p>(3) </p><p>The function f (u, v) is positive outside the circle and is negative inside the circle. As shown in Fig. 1, if we assume the current node is P(ut, vi), the candidate </p><p>point is A or B, and the decision criterion is whether the distance d a is larger than d B or not. It is known that if R is large enough, d4 and d s are nearly proportional to [ f (u i, vi + 1)1 and [f(u i + 1, v~ + 1) I, respectively: </p><p>d._..~A ~ If(u,, v, + I)1 (4) d,, l-f(",+ I,~,+ I)I" </p><p>In the first sextant, there are three candidate directions for step i + 1: l-link move (60~ 2-1ink move (120~ 3-1ink move (180~ following the notation of Freeman [1]. </p><p>401 0146-664X/81/040401-02502.00/0 Copyright 9 1981 by Academi~ Preas, Inc. All dght~ of rcproductinn in any form reserved. </p></li><li><p>402 KENSUKE SHIMIZU </p><p>FIo. 1. Circle on a triangular grid with coordinate system u, v. </p><p>The f(u, v) corresponding to each move are given as follows. </p><p>Z, =f (u , + 1,v i + 1) =f(ul ,v,) + u i + v, + 1, </p><p>Z 2 - - f (u i,v i+ 1)----f(ui ,v,)-- ut+2v i+ 1, </p><p>Z 3 - - f (u i - 1,vi) =f (u i ,v i ) - -2u i+v i+ 1. </p><p>(5) (6) (7) </p><p>Note that the operations involved in (5), (6), and (7) are addition, subtraction and shifting. Furthermore, if the initial point is exactly on the triangular grid, f (u o, Vo) equals zero. Then we arrive at the following algorithm. </p><p>A1. [Initialize] Set i ~ 0, u ~-- u o, v ~ v 0, and f (u, v) ~ 0 if the initial point is on the triangular grid. </p><p>A2. Obtain Z1, Z2, Z 3 from (5), (6), or (7), respectively. A3. Obtain Zj ( j = 1, 2 or 3) which gives minimum absolute value among Z 1, Z 2 </p><p>and Z 3. A4. Make a j- l ink move, replace f(ui, vi)with Zj, and return to step A2. </p><p>The extension to sextants other than the first is straightforward. For example, in the second sextant, it is only necessary to interchange the .blink move in the first sextant with a ( j + 1)-link move. </p><p>REFERENCE 1. H. Freeman, Algorithm for generating a digital straight line on a triangular grid, IEEE Trans. </p><p>Computers C-28, 1979, 150-152. </p></li></ul>

Recommended

View more >