JPH03147190A - Straight line drawing method - Google Patents

Straight line drawing method

Info

Publication number
JPH03147190A
JPH03147190A JP28677989A JP28677989A JPH03147190A JP H03147190 A JPH03147190 A JP H03147190A JP 28677989 A JP28677989 A JP 28677989A JP 28677989 A JP28677989 A JP 28677989A JP H03147190 A JPH03147190 A JP H03147190A
Authority
JP
Japan
Prior art keywords
straight line
value
points
point
drawn
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP28677989A
Other languages
Japanese (ja)
Inventor
Keizo Azuma
圭三 東
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP28677989A priority Critical patent/JPH03147190A/en
Publication of JPH03147190A publication Critical patent/JPH03147190A/en
Pending legal-status Critical Current

Links

Landscapes

  • Image Generation (AREA)

Abstract

PURPOSE:To efficiently draw a straight line at high speed by simultaneously drawing plural drawing points by utilizing a fact that the number of the drawing points arranged laterally in one line is increased for a slightly inclined straight line. CONSTITUTION:When the straight line is displayed in a pit map memory, an inverse formula 1/a=t+s((t) is an integer number, 0<=s<1) is calculated while defining the inclination of the real straight line as (a), and from the calculated inclination (a), a value (b) is calculated by a formula b=1/2-(t)X(a). Next, while defining a distance between a first point of a continuous dot sequence and the real straight line as (d), the (d) is compared with the (a) and at the time of d>=d, the number of the continuous dots is defined as t+1. Then, at the time of d<b, the number of the continuous dots is defined as the (t). The sequence of dots is drawn only by the calculated number and the value of the (d) is corrected to a formula d=(d)+(a)X(the number of drawing points)-1. Next, it is checked whether all the dot sequences are finished being drawn or not, and when it is not finished, the same drawing operation is repeated to get back to the beginning. Thus, the straight line can be efficiently drawn at high speed.

Description

【発明の詳細な説明】 [概要コ コンピュータの表示装置として使用されるビットマツプ
メモリに直線を描画する場合における直線描画方法に関
し、 直線の描画を高速で効率よく行うことを目的とし、 ビットマツプメモリに直線を表示させる場合において、
実際の直線の傾きをaとしてその逆数1/a 1 / a =t + s  (tは整数、0≦s<1
)を演算し、 求めた傾きaより次式で示される値b b−1/2=t×a を求め、 次に、連続する点列での最初の点と実際の直線との距離
をdとしてdとaを比較しd≧dの時には連続する個数
を(+1個とし、dabの時には連続する個数をt個と
し、求まった数だけ点列を描画し、dの値を次式で示さ
れるdの値d=d+aX(描画点の個数)〜〕 に修正し、 次に全て点列の描画が終了したかとうかチェックし、終
了していない場合には前に戻って同じ描画操作を繰返す
ように(1育成する。
[Detailed Description of the Invention] [Summary] Regarding a straight line drawing method when drawing a straight line on a bitmap memory used as a display device of a cocomputer, the purpose of this invention is to draw a straight line at high speed and efficiently. When displaying a straight line in
Let the slope of the actual straight line be a, then its reciprocal 1/a 1/a = t + s (t is an integer, 0≦s<1
), and from the obtained slope a, find the value b shown by the following formula: b-1/2=t×a. Next, calculate the distance between the first point in the series of consecutive points and the actual straight line by d. Compare d and a, and when d≧d, the number of consecutive points is (+1), and when dab, the number of consecutive points is t, draw the determined number of point sequences, and express the value of d using the following formula. Correct the value of d to be d = d + a Like (1 to cultivate.

[産業上の利用分野〕 本発明はコンピュータの表示装置として使用されるビッ
トマツプメモリに直線を描画する場合における直線描画
方法に関する。
[Industrial Application Field] The present invention relates to a straight line drawing method for drawing a straight line on a bitmap memory used as a computer display device.

近年、コンピュータの表示装置として、デイスプレィ上
の画素毎に対応するメモリを割当てるビットマツプメモ
リが多用されるようになってきており、このメモリ上に
擬似的に直線を描画する方法か要求されてきている。
In recent years, bitmap memory, which allocates memory corresponding to each pixel on the display, has come into widespread use as a computer display device, and a method for drawing pseudo straight lines on this memory has been required. There is.

[従来の技術] ビットマツプメモリは、格子上に点が存在するので、直
線を描画する場合、その直線に最も近い格子点を選択し
、それらを描画することにより、擬似的に直線を表示す
るようになっている。従来の描画方式ではDDA (D
igital  Differential  Alg
orithm)が有名である。この方法は、実際の直線
とその直線に最も近い描画点との差を用いて次に描画す
べき点を決定する方法である。
[Prior art] Bitmap memory has points on a grid, so when drawing a straight line, it selects the grid points closest to the straight line and draws them to display a pseudo straight line. It looks like this. In the conventional drawing method, DDA (D
digital Differential Alg
orithm) is famous. This method uses the difference between an actual straight line and the drawing point closest to the straight line to determine the next point to be drawn.

第4図は従来の描画方式の説明図である。図に示す格子
点漢の距離は1に正規化されているものとする。図にお
いて、Ωが実際の直線である。
FIG. 4 is an explanatory diagram of a conventional drawing method. It is assumed that the distance between the grid points shown in the figure is normalized to 1. In the figure, Ω is an actual straight line.

今、図のPlが描画点であるものとすると、実際の直線
gと描画点21間の附属はdである。ここで、この直線
の傾きをa(Q<a<1.)とすると、その関係は第5
図に示すようなものとなる。
Now, assuming that Pl in the figure is a drawing point, the attachment between the actual straight line g and the drawing point 21 is d. Here, if the slope of this straight line is a (Q<a<1.), then the relationship is the fifth
The result will be as shown in the figure.

Plの次の描画点は、y値を+1したP2か、y値、y
値ともに+1したP3のうちのいずれか一方となる。
The next drawing point after Pl is P2 with the y value +1, or the y value, y
It becomes either one of P3 whose values are both +1.

この場合、d+a (dは正負の値をとるものとする)
が0.5よりも大きい場合には、直線Ωが格子と交わる
点AがP2とP3のどちらに近いかで決まる。d+aが
0.5よりも小さい時はP2が直線gに近いことになり
P2が次の描画点となる。これに対し、d+aが0.5
よりも大きい場合にはP3の方が直線gに近いことにな
り、P3が次の描画点となる。
In this case, d+a (d assumes a positive or negative value)
is larger than 0.5, it is determined by which point A, where the straight line Ω intersects with the grid, is closer to P2 or P3. When d+a is smaller than 0.5, P2 is close to the straight line g, and P2 becomes the next drawing point. On the other hand, d+a is 0.5
If it is larger than , P3 is closer to straight line g, and P3 becomes the next drawing point.

このようにして1点ずつ描画点を算出しながら直線を描
画する方法がDDAである。
DDA is a method of drawing a straight line while calculating drawing points one by one in this way.

[発明が解決しようとする課題] 従来の直線描画方法は、前述したように1点ずつ描画点
を算出しながら直線を描画していく方法であるので、メ
モリへのアクセスが描画点の個数たけ必要となり、処理
に要する時間がかかっていた。
[Problems to be Solved by the Invention] The conventional straight line drawing method is a method of drawing a straight line while calculating the drawing points one by one as described above, so the access to the memory is equal to the number of drawing points. This required a long time for processing.

本発明はこのような課題に鑑みてなされたちのてあって
、直線の描画を高速で効率よく行うことができる直線描
画方法を提供することを目的としている。
The present invention has been made in view of these problems, and an object of the present invention is to provide a straight line drawing method that can draw straight lines efficiently and at high speed.

[課題を解決するための手段] 第1図は本発明方法の原理を示すフローチャートである
。本発明は、 ビットマツプメモリに直線を表示させる場合において、 実際の直線の傾きをaとしてその逆数1/a1、 / 
a = t + s  (tは整数、0≦sく1)を演
算しくステップ1)、 求めた傾きaより次式で示される値b b = 1 / 2− t x a を求め(ステップ2)、 次に、連続する点列での最初の点と実際の直線との距離
をdとしてdとaを比較しくステップ3)d≧dの時に
は連続する個数をt+1個とし、d<bの時には連続す
る個数をt個としくステッブ4)、 求まった数だけ点列を描画しくステップ5)、dの値を
次式で示されるdの値 d=d+aX(描画点の個数)−1 に修正しくステップ6)、 次に全て点列の描画が終了したかどうかチェックしくス
テップ7)、終了していない場合にはステップ3まで戻
って同じ描画操作を繰返すようにしたことを特徴として
いる。なお、ここで、比較の対象とされるdとbの値は
その絶対値で考えるものとする。
[Means for Solving the Problems] FIG. 1 is a flowchart showing the principle of the method of the present invention. In the present invention, when displaying a straight line in the bitmap memory, the slope of the actual straight line is a, and its reciprocal is 1/a1, /
Calculate a = t + s (t is an integer, 0≦s×1) (Step 1), and from the obtained slope a, calculate the value b b = 1 / 2 - t x a given by the following formula (Step 2) Next, let d be the distance between the first point in the series of consecutive points and the actual straight line, and compare d and a. Step 3) When d≧d, the number of consecutive points is t+1, and when d<b, Step 4) Set the number of consecutive points to t. Step 5) Adjust the value of d to d = d + aX (number of drawing points) - 1, which is expressed by the following formula. The process is characterized in that it correctly checks step 6), then checks step 7) to see if all point sequences have been drawn, and if not, returns to step 3 and repeats the same drawing operation. Note that the values of d and b to be compared are considered in terms of their absolute values.

[作用] 傾きの小さい直線は、それだけ横一列に並ぶ描画点の数
が増えることに着目して一度に複数個の描画点を描画す
るようにした。これにより直線の描画を高速で効率よく
行うことができる直線描画方法を提供することができる
[Operation] We focused on the fact that a straight line with a small slope increases the number of drawing points that are lined up horizontally, so a plurality of drawing points are drawn at once. This makes it possible to provide a straight line drawing method that can draw straight lines at high speed and efficiently.

[実施例] 以下、図面を参照して本発明の実施例を詳細に説明する
[Example] Hereinafter, an example of the present invention will be described in detail with reference to the drawings.

第2図は本発明方法を実施するシステム構成例を示す図
である。図において、1は実際の直線と描画点との差分
dを保持する第1のレジスタ、2は連続する描画点の個
数を算出するために使用される第2のレジスタであり、
描画に先立って傾き値aより算出された定数すがセット
される。
FIG. 2 is a diagram showing an example of a system configuration for implementing the method of the present invention. In the figure, 1 is the first register that holds the difference d between the actual straight line and the drawing point, 2 is the second register used to calculate the number of consecutive drawing points,
Prior to drawing, a constant calculated from the slope value a is set.

3は第1及び第2のレジスタの出力dとbとを比較して
連続する描画点の個数を決定する比較器、4は決定され
た連続する描画点の個数によりビットマツプメモリ5に
点を描画する描画部である。
3 is a comparator that compares the outputs d and b of the first and second registers to determine the number of consecutive drawing points, and 4 stores points in the bitmap memory 5 according to the determined number of consecutive drawing points. This is a drawing section that draws.

ここで、連続する描画点とは、同−関数軸値をもつ点の
ことをいう。また、関数軸とは傾きが1以上の場合はy
軸、傾きか1以’FO以上の場合X軸をさす。以下の説
明では、傾きが0以上1以ドの場合について述べる。そ
の他の場合については、従来のDDAと同様に、適宜座
標変換を行うことにより同様に適用することができる。
Here, continuous drawing points refer to points having the same function axis value. Also, the function axis is y if the slope is 1 or more.
If the axis or inclination is 1 or more and FO or more, point to the X-axis. In the following explanation, a case where the slope is 0 or more and 1 or less will be described. For other cases, the present invention can be applied in the same manner as the conventional DDA by performing appropriate coordinate transformation.

第3図は本発明方法による描画例を示す図である。第2
図を用いて本発明方法の実施例を詳細に説明する。第3
図の例では、傾きa−215の直線を描画する場合を示
している。この場合、連続する点列の個数として、傾き
aの逆数が5/2−2.5であるので、2又は3が考え
られる。ここで、連続する描画点列の個数を決定するた
めの定数すを求める。
FIG. 3 is a diagram showing an example of drawing by the method of the present invention. Second
Embodiments of the method of the present invention will be described in detail with reference to the drawings. Third
In the example shown in the figure, a straight line with an inclination of a-215 is drawn. In this case, since the reciprocal of the slope a is 5/2-2.5, the number of consecutive point sequences is considered to be 2 or 3. Here, a constant for determining the number of consecutive drawing point sequences is determined.

b−1/2−2X (215)−−3/10となる。こ
のbの値はレジスタ2に格納される。
b-1/2-2X (215) --3/10. This value of b is stored in register 2.

一方、第3図より点Pでの差分値dは−115である。On the other hand, from FIG. 3, the difference value d at point P is -115.

この差分値dはレジスタ1に格納される。This difference value d is stored in register 1.

比較器3はレジスタ1,2に格納されているbの値とd
の値の絶対値同志とを比較する。d−115、b−3/
10であるので、dabとなる。従って、比較器3はP
点を含めて点列の個数は2個と判定する。描画部3は、
比較器3の出力を受けてビットマツプメモリ5の所定位
置に2個連続して描画する。この結果、点Pを含めて2
個目−y座標値の点が連続することになる。
Comparator 3 compares the value of b and d stored in registers 1 and 2.
Compare the absolute values of the values of . d-115, b-3/
Since it is 10, it becomes dab. Therefore, comparator 3 is P
The number of point sequences including the points is determined to be two. The drawing section 3 is
In response to the output of the comparator 3, two images are drawn consecutively at a predetermined position in the bitmap memory 5. As a result, 2 including point P
The points with the -y coordinate value are consecutive.

次に点Sでの差分値dを求めると、点Pでの差分値d−
−115より d−−1,15+(215)x2−1 −215 となる。この値はレジスタ1に格納される。そして、比
較器3はレジスタ1に格納されているdの値−215と
レジスタ2に格納されているbの値3/10の絶対値同
志を比較する。dはbよりも大きいので、比較器3は描
画点列の個数は3であると判定する。描画部3は、比較
器3の出力を受けてビットマツプメモリ5の所定位置に
3個連続して描画する。この結果、点Sを含めて3個同
−y座標値の点が連続することになる。
Next, when calculating the difference value d at point S, the difference value d- at point P is
-115, it becomes d−1,15+(215)x2−1 −215. This value is stored in register 1. Then, the comparator 3 compares the absolute values of the value of d stored in the register 1, -215, and the value of b, 3/10, stored in the register 2. Since d is larger than b, the comparator 3 determines that the number of drawing point sequences is three. The drawing unit 3 receives the output of the comparator 3 and draws three images in succession at a predetermined position in the bitmap memory 5. As a result, three points including point S with the same -y coordinate value are consecutive.

次に、点Tでの差分値を求めると、点Sでの差分値d−
−215より d−−215+ (215)X3−1 −115 となる。この値はレジスタ1に格納される。そして、比
較器3はレジスタ1に格納されているdの値−115と
レジスタ2に格納されているbの値3/10の絶対値同
志を比較する。dはbよりも小さいので、比較器3は描
画点列の個数は2であると判定する。描画部3は、比較
器3の出力を受けてビットマツプメモリ5の所定位置に
2個連続して描画する。この結果、点Tを含めて2個同
−y座標値の点が連続することになる。
Next, when calculating the difference value at point T, the difference value d− at point S is
-215, it becomes d−-215+ (215)X3-1 −115. This value is stored in register 1. Then, the comparator 3 compares the absolute values of the value of d stored in the register 1, -115, and the value of b, stored in the register 2, of 3/10. Since d is smaller than b, the comparator 3 determines that the number of drawing point sequences is two. The drawing section 3 receives the output of the comparator 3 and draws two consecutive images at a predetermined position in the bitmap memory 5. As a result, two points including point T with the same -y coordinate value are consecutive.

このようなシーケンスを繰返すことにより、直線を描画
することができる。本発明によれば同時に複数個の描画
点を得ることができるので、1個ずつ求めていた従来方
式に比較して描画速度が向上する。
By repeating such a sequence, a straight line can be drawn. According to the present invention, since a plurality of drawing points can be obtained simultaneously, the drawing speed is improved compared to the conventional method in which drawing points are obtained one by one.

上述の説明ては、31算のハ礎として分数を用いたが、
一般にコンピュータでは分数や少数の引算は不得手であ
り、定数値を乗じることにより整数化し、整数値を用い
て計算及び比較を行わせた方が処理速度が速くなる。
In the above explanation, fractions were used as the basis for 31 arithmetic, but
Generally, computers are not good at subtracting fractions and decimals, so processing speed is faster if they convert the numbers into integers by multiplying them by constant values, and perform calculations and comparisons using the integer values.

また、比較を行なわせる場合、定数値よりも0との比較
の方が一般に速度は速くなるので、予め差分値dから定
数すの値を減しておいて、以降は0との比較により条件
を判定するようにしてもよい。
Also, when performing a comparison, the speed of comparison with 0 is generally faster than with a constant value, so subtract the value of the constant d from the difference value d in advance, and then use the comparison with 0 to set the condition. may be determined.

[発明の効果] 以上、詳細に説明したように、本発明によれば傾きの小
さい直線は、それだけ横一列に並ぶ描画点の数か増える
ことに着目して一度に複数個の描画点を描画するように
した。これにより直線の描画を高速で効率よく行うこと
ができる直線描画方法を提供することができる。
[Effects of the Invention] As described in detail above, according to the present invention, a straight line with a small slope increases the number of drawing points arranged in a horizontal line, and a plurality of drawing points are drawn at once. I decided to do so. This makes it possible to provide a straight line drawing method that can draw straight lines at high speed and efficiently.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は本発明方法の原理を示すフローチャート、 第2図は本発明方法を実施するシステム構成例を示す図
、 第3図は本発明方法による描画例を示す図、第4図は従
来の直線描画方式の説明図、第5図は直線の傾きを示す
図である。 第2図において、 1.2はレジスタ、 3は比較器、 4は描画部、 5はビットマツプメモリである。 本発明方法を実施するシステム構成例を示す同第2図 本発明方法の原理を示すフローチャート第1図 本発明方法]二よる描画例を示す同 第3図 従来の直線描画方式の説明図 第4図 直線の傾きを示す図 第5図
Fig. 1 is a flowchart showing the principle of the method of the present invention, Fig. 2 is a diagram showing an example of a system configuration for implementing the method of the present invention, Fig. 3 is a diagram showing an example of drawing by the method of the present invention, and Fig. 4 is a diagram showing the conventional method. FIG. 5, which is an explanatory diagram of the straight line drawing method, is a diagram showing the slope of the straight line. In FIG. 2, 1.2 is a register, 3 is a comparator, 4 is a drawing section, and 5 is a bitmap memory. Fig. 2 shows an example of a system configuration for carrying out the method of the present invention. Fig. 1 is a flowchart showing the principle of the method of the invention. Fig. 3 shows an example of drawing based on the method of the invention. Diagram showing the slope of the straight line Figure 5

Claims (1)

【特許請求の範囲】 ビットマップメモリに直線を表示させる場合において、 実際の直線の傾きをaとしてその逆数1/a1/a=t
+s(tは整数、0≦s<1) を演算し(ステップ1)、 求めた傾きaより次式で示される値b b=1/2−t×a を求め(ステップ2)、 次に、連続する点列での最初の点と実際の直線との距離
をdとしてdとaを比較し(ステップ3)d≧dの時に
は連続する個数をt+1個とし、d<bの時には連続す
る個数をt個とし(ステップ4)、 求まった数だけ点列を描画し(ステップ5)、dの値を
次式で示されるdの値 d=d+a×(描画点の個数)−1 に修正し(ステップ6)、 次に全て点列の描画が終了したかどうかチェックし(ス
テップ7)、終了していない場合にはステップ3まで戻
って同じ描画操作を繰返すようにしたことを特徴とする
直線描画方法。
[Claims] When displaying a straight line in a bitmap memory, the slope of the actual straight line is a, and its reciprocal 1/a1/a=t
+s (t is an integer, 0≦s<1) (step 1), and from the obtained slope a, calculate the value b shown by the following formula (step 2), then , compare d and a with d being the distance between the first point in the series of consecutive points and the actual straight line (Step 3) If d≧d, the number of consecutive points is t+1, and if d<b, the number of consecutive points is t+1. Set the number to t (step 4), draw the determined number of point sequences (step 5), and correct the value of d to the value of d shown by the following formula: d = d + a × (number of drawing points) - 1 (Step 6), and then checks whether all point sequences have been drawn (Step 7), and if not, returns to Step 3 and repeats the same drawing operation. How to draw straight lines.
JP28677989A 1989-11-02 1989-11-02 Straight line drawing method Pending JPH03147190A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP28677989A JPH03147190A (en) 1989-11-02 1989-11-02 Straight line drawing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP28677989A JPH03147190A (en) 1989-11-02 1989-11-02 Straight line drawing method

Publications (1)

Publication Number Publication Date
JPH03147190A true JPH03147190A (en) 1991-06-24

Family

ID=17708943

Family Applications (1)

Application Number Title Priority Date Filing Date
JP28677989A Pending JPH03147190A (en) 1989-11-02 1989-11-02 Straight line drawing method

Country Status (1)

Country Link
JP (1) JPH03147190A (en)

Similar Documents

Publication Publication Date Title
EP0577130B1 (en) System and method for rendering bézier splines
EP1127337B2 (en) Shading 3-dimensional computer generated images
US7173633B2 (en) Method and system for inversion of detail-in-context presentations
US20020094132A1 (en) Method, apparatus and computer program product for generating perspective corrected data from warped information
US6295072B1 (en) Method and apparatus for rendering cubic curves
JP3352181B2 (en) Image data processing method and apparatus
EP0388089B1 (en) Image processing apparatus
EP0349182B1 (en) Method and apparatus for approximating polygonal line to curve
US7015930B2 (en) Method and apparatus for interpolating pixel parameters based on a plurality of vertex values
JPH03147190A (en) Straight line drawing method
US4945497A (en) Method and apparatus for translating rectilinear information into scan line information for display by a computer system
US6646648B1 (en) Method and system for evaluating derivatives in screen space using perspective corrected barycentric coordinates
JP3059739B2 (en) Information processing apparatus with curve drawing function and processing method
JP2878614B2 (en) Image synthesis method and apparatus
JPS6232519B2 (en)
JPS59229669A (en) Picture data processor
EP0339758A2 (en) Image processing apparatus for performing projective transformations
JPH0660195A (en) Curved surface display device
JP2806185B2 (en) Polygon filling device
JP2861097B2 (en) Shading image generation method and apparatus
JP2861106B2 (en) Shading image generation method and apparatus
JPH0261779A (en) Coordinate data processing unit
JP2932664B2 (en) 1-pass type figure shape feature quantity calculation device
JPS62205482A (en) Segment generating circuit of crt display device
JP2780496B2 (en) Clipping method for drawing equipment