LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAICN ho. 2>2>l-33& cop. 2 The person charging this material is re- sponsible for its return to the library from which it was withdrawn on or before the Latest Date stamped below. Theft, mutilation, and underlining of books are reasons for disciplinary action and may result in dismissal from the University. UNIVERSITY OF ILLINOIS LIBRARY AT URBANA-CHAMPAIGN L161 Digitized by the Internet Archive in 2013 http://archive.org/details/solutiontohidden335mats r J0.7¥ Report No. 335 A SOLUTION TO THE HIDDEN LINE PROBLEM June 1, 1969 by Yutaka Matsushita ffll UBRMW Of W JUL 9 1969 ■MOW «FUW» Report No. 335 A SOLUTION TO THE HIDDEN LINE PROBLEM by Yutaka Matsushita June 1, I969 Department of Computer Science University of Illinois at Urbana-Champaign Urbana, Illinois 6l801 * This work was supported in part by the Advanced Research Projects Agency as administered by the Rome Air Development Center under Contract No. US AF 30(602)*+LM+ and submitted in partial fulfillment of the requirements for the degree of Master of Science in Computer Science, June, 1969. 11 ABSTRACT A method which is concerned with determining by a computer, which parts of three-dimensional objects are visible and which are invisible, when the objects are viewed from a viewpoint is discussed. A decomposition technique by which any concave polygon can be decomposed into convex polygons is used in order to obtain the relationship between any pair of polygons from each of which the hidden lines can be elimi- nated from the original picture. Furthermore, in order to reduce operation time, the scheme is used in which the comparisons are eliminated for the pairs of poly- gons having no intersection on the view plane. This method is prefer- able for the hidden line elimination of a rotating or moving object. Ill ACKNOWLEDGMENT The author wishes to thank Professor D. L. Slotnick and Mr. A. B. Carroll for their helpful guidance, Mr. R. E. Marks for many "beneficial discussions, Mr. J. A. Studier for his advice and Mr. J. S- Kravitz for assistance in the writing of a part of the program. Finally, the author would like to thank Mrs. Mildred Pape, Mrs. Pat Stippes and Mrs. Patricia Douglas for typing this thesis. IV TABLE OF CONTENTS 1. INTRODUCTION 1 2. THREE-DIMENSIONAL POLYHEDRA 3 2.1 Polygon Generation and Data Structure 3 2.2 Relationships Between Two Polygons 10 2.2.1 Types of Relationships 11 2.2.2 Deterministic Procedure of Relationships .... 12 2.2.3 Reduction of Computation Time 22 3. THREE-DIMENSIONAL OBJECTS WITH CURVED SURFACES 27 3.1 The Method to Determine the Relationship Between Two Curved Surfaces 28 h. HIDDEN LINE ELIMINATION 35 k.l Local Hidden Line Elimination 35 k.2 Global Hidden Line Elimination 37 5. EXAMPLE AND RESULT ON B5500 38 6. CONCLUSION kG LIST OF REFERENCES 5*+ 1. INTRODUCTION A problem of particular current interest in the area of computer graphics is the so-called hidden line problem. This problem is concerned with determining by a computer, which parts of three- dimensional objects are visible and which are invisible, when the objects are viewed from an arbitrary point. Applications dealing with any form of spatial design need the ability to represent objects and their relationships to each other in three-dimensional space. This requirement increases as the variety and complexity of pictures increases. No satisfactory algorithms exist as yet for solving this problem rapidly and efficiently on a digital computer. A simple, fast algorithm is essential because today there are many applications for which it is desirable to view a moving object on a cathode-ray tube. However, to the surprise of most investigators, the problem has proved to be unusually complex. The main obstacle in accomplishing this task is that much computation is required to decide which parts of three-dimensional objects are seen and which are hidden from view. This paper describes an approach to the problem that is desirable only because it is simple and basic for general graphics problems, but not because computation time is reduced. However, if parallel processing is available (ILLIAC IV), computation time can be greatly reduced. This paper is mainly concerned with the following two structures: 1) Three-dimensional poly] opaque polygons. Line segment end-points, are assumed as the input data. Three-dimensional objects are described by a set of line segments. This will be discussed in Chapter 2. 2) Three-dimensional objects including curved suri into triangles, where each decomposed triangle of tl /ed surfaces must be completely specified as the input da" This will be discussed in Chapter 3- Hidden line problems for both cases will be discussed in Chapter h. 2. THREE-DIMENSIONAL POLYHEDRA 2.1 Polygon Generation and Data Structure Line segments, specified by end-points pairs, are assumed as the input. This input is specially processed to put it in the desired form. Each line is assigned to a line block in a line list, and each point is assigned to a point block. Each point indicates which lines are connected to it, and each line block points to its end points. The list structure format is a good form for graphics processing. The first problem is to find the polygons described by the line segments. Polygon generation method is described as follows: Consider a cube, for example, and let all lines be numbered as shown in Figure 1A. IB Figures LA. and IB. Step 1. Select an arbitrary line from input data. Step 2. Select one of end-points of the selected line as a starting point. Step 3. Search for linei ch have tin irertes point of the selected line, determine the new and generate a tree. Step h. Continue Step 3 for new starting until all termina_ of the tree are terminated. Terminating Criteria 1) If an identically labeled number is found in the higher level of the tree, terminate the branch, which is shown in Figure IB as an encircled number. 2) If an identically labeled number is found in the left- hand side of the terminal being considered, terminate the branch. 3) Terminate all branches having the same root as the desired terminal which has the same labeled number as the line segment selected in Step 1, even if they do not appear in the higher level or left-hand side of them. This can be seen in Figure 2. In this case, the terminal labeled 1 is a desired terminal (double encircled terminal) which has a root labeled 6. Figure 2. Terminals 5 and 7 must be terminated even if those labels do not appear in the higher levels or left-hand side of them. By using this method, two polygons can be generated simulta- neously if the tree is followed backward from the desired terminals. In the example as shown in Figure 1, polygons with lines 1, 2, 3 and k and with lines 1, 10, 11 and 5 are generated. 1 2 3 k 5 6 7 8 9 10 11 12 2 1 1 1 1 1 1 Figure 3. Used Line Table As polygons are generated, the used line table which shows how many times each line is used, is rewritten. Next, choose one of the lines which has "0" in the used line table. If there is no line which has "0", choose one of the lines which has "1" in the table. Apply procedure Steps 2 through k; if a new polygon is generated, the used line table is modified. When entries of the table become 2, there exists no missing polygon because two polygons determine a line. The tree representation structure shown in Figure h is used. LINE denotes line name, FOWL points leftmost descendant (FOWL [i] = means that the branch i is terminated and FOWL [i] <0 means the desired terminals) and the parent of aJ 3 BACK. In GENERATION POINTERS, the and the addresses of the desired terminals are r:hown al . Figure h is part of the computer output of the data own in Figures 5A, 5B and 5C. r.ENFRATTON PTTNTrKS 6 p m ft n o r TRFF FDR PARFMT 1 Jfc-F ( 1 ) ADDf 1. IMF F o w n PA(K 1 1 1 1 2 *> 9 2 9 2 /j 1 3 /J 1 1 fl ft 1 /J 8 /I 3 8 7 S 1 ft s 1 3 10 ? ft ->ix * 10 1? 3 7 14 7 1 1 1 * 3 8 a 1 6 4 TERMINAL 1 Af)nRF^S= 13 1 n i« /i TERMINAL 2 Ann«F<;s= 2/i 10 1 l s 11 1? 20 b 1? 9 22 6 n 1 7 -1 ft , i/i 1 2 P 7 1* 1 3 7 if 5 9/1 8 17 1 S 2ft 8 1« 7 28 9 1° 1 2 Q 2* 7 n 1 I 21 1 a n 11 22 6 30 12 23 1 ft 32 1 2 24 ft -2 1 ft 2S 1 6 1ft 2ft 7 1 7 27 e p 1 7 2* 8 o 1 8 20 15 18 30 7 p 77 31 1 S 22 3? 5 n 2 3 31 6 23 3'i Figure U. 5A LINE OATA RLOTK LINT PhTl P\|T2 USED 1 2 4 ? 9 2 1? ? 3 1? 3 2 4 1 3 ? S 10 1 2 6 4 10 2 7 9 8 2 * 9 1 1 2 1 1 5 2 10 5 6 2 11 7 6 2 1? 7 5 2 n 7 1? 2 14 3 a 2 1"! 1 9 2 If 10 11 2 17 '4 5 2 1« 2 6 ? 5C POINT 1 0.00000 1 .00000 1 .00000 •> 1 .00000 1 ,00000 0,00000 3 1 .00000 1 .ooooo 1 .ooooo /J o.ooooo 1 ,00000 0.00000 5 o.ooooo 0,0000^ 0.00000 A 1 ,00000 0,00000 0.00000 7 1 .50000 o.ooooo 0,50000 « 1 ,00000 0,00000 1 .ooooo o.ooooo o.ooooo 1 .ooooo 10 -0.50000 1 .ooooo 0.50000 1 1 -0.50000 n .ooOOn 0.500 00 1? 1 ,50000 1 .00000 0.50000 5B Figures 5A, 5B and 5C. A good method of storing three-dimensional data -.ely important. The structure used is the basis for both the display pro- gram and the three-dimensional construction. A 11 ."ucture of linked blocks is used. The point blocks are linked to the lin connected to them and include a three-component-position vector (x, y, z). The line blocks are linked to two point blocks (PNTl and PNT2) and two polygon blocks (PG1 and PG2), since two polygons determine a line The polygon blocks are linked to a ring of lines which represent the surface polygon. The computer output of Figure 5A is shown in Figures 5D and 5E. LTNF 0A7A BLOCK AOOR LI^'F PnjT 1 P M? PPM PGu? RTMG 1 1 7 U 5 1 8 9 ? 10 5 6 1 4 3 •* 1P ft 1 5 a 1 ? H 1 2 1 s ft h 10 7 8 ft 6 5 10 1 9 7 7 7 4 1 3 •5 3 a 8 3 12 3 r> ft 9 2 2 12 2 5 1 1* 1 2 4 ? 1 5 11 1 n 3 P 1 ft 12 19 n 1 3 T| 2 1 3 1 * 1 s 1 9 3 7 1 ix l'J 7 8 3 t\ It IS 12 7 8 a ft 1ft If 1 1 7 ft /i 5 17 |7 1 n 5 ft /j 1 1 8 1 « 9 1 1 S 4 8 19 19 8 9 1 1 /i 7 20 ?n 7 p 8 h 3 15 21 2 2 12 s 2 2 2 POLYGON flnORFSS 2? 1 8 2 ft s 1 23 PLGM ADOR ?3 1 1 7 ft s a 24 2fl 1 3 7 12 5 ft 21 1 1 ?«? 3 12 3 a 2 2ft 9 5 2* 1 h 3 8 A 3 9.7 3 1 1 2^ i 2 7 8 ft 4 98 n 15 2« 13 7 12 A s 25 5 '1 ?0 8 9 11 7 IX 30 ft ^5 3n 1 5 1 9 7 3 31 7 ?9 31 s 10 1 7 2 32 8 33 3? 16 1 1 1 7 8 29 3"* 9 1 1 5 Q 4 34 3A 17 4 S A 1 35 3* ft IX 10 £ 2 3ft 3* 1 ft 10 1 1 a 7 3 3 5E 5D Figures 5D and 5E. 2 . 2 Relation:: hi p:: -.';tween Twr 01 To motivate the di line problem, factors which determine whether or not part are visible must be considered. For a single polyhedrc of polygons, a polygon'" visibility, partial visibility, or invisi- bility is determined by whether or not it is behind another opaque polygon. A problem involving only one polyhedron give. to what can be called local hidden lines . For a compound structure of polyhedra, locally visible polygons of a polyhedron may become invisible or partially invisible by the polygons of another poly- hedron, as shown in Figure 6. Figure 6. Compound Structure If a compound structure of polyhedra is being considered, global hidden lines can occur. In either case, if the relationship between « two polygons can be determined, the hidden line problem may be solved. 11 2.2.1 Types of Relationships The possible configurations of two polygons may be classified into three distinct types. a) One encloses the other. b) One is involved by the other. c) There is no intersection between them. Since any three-dimensional objects can be projected on the two- dimensional view plane, the relationships described above must be defined on the projected two-dimensional view plane. The three types of relationships are illustrated in Figure 7. Relationship a) Relationship b) Relationship c) Figure 7. 2.2.2 Determirii-tic Procedure of Relation Any polygon, whether convex or concave, determin- sub space S such that s.eS (i = 1, 2, . . . , m) ScE where s. is a member of S, which represents a position, and E denotes the entire space. The set of points which lie within a convex polygon can be determined uniquely by the following propositional equation S = i-jAigA.-.-Ai where i.(i =1, •••, n) is an infinite line containing the ith line s egment . Figure 8. However, we have to decide which half -plane produced by the infinite line contains the polygon. This can easily be done in the following way. Choose a vertex which does not lie on the selected line and determine on which side of the infinite line the vertex lies. 13 For a convex polygon, the propositional form can easily be specified. The word "propositional" is used because, given a point, it can easily be determined whether or not it lies in (it looks like a binary relation "true and false"). However, for a concave polygon, it is believed that no way exists to determine a propositional equation without using polygon decomposition, which is discussed later. Definition of negative and positive vertex: A vertex is called positive if its interior angle is less than ir radians, and is called negative if its interior angle is greater than ir radians. Heavy dots in Figure 9 show negative vertices, Figure 9- Ik Whether a vertex is positive or negative can usually b< mined using the notion of a cross produ' YMAX X P = P X Q 10A. Cross Product YMIN XMIN XMAX 10B. Concave Polygon Figures 10A and 10B. The cross product of vectors P and Q, in space (Figure 10A) is defined as the vector R whose magnitude equals the product of the magnitude of P and Q, multiplied by the sine of the angle (less than 180 degrees) "between P and Q. The direction of R is the direction of advancement of a right-hand screw when revolved from P to Q through the smaller of the angles between them. By using the right-hand rule it is seen that PXQ = -QXP and hence, the commutative law does not hold for the cross product. Select an arbitrary vertex at which two vectors are incident (for example, 17, 12). The components of these vectors can be specified by AX and AY with the sign as shown in Figure 10B. 15 (AX, AY) X (AX', AY') = AXAY' - AYAX' = C By using the above equation, we can determine whether a vertex is positive or negative. Case 1: Clockwise If C> 0, then vertex i is positive, If C.< 0, then vertex i is negative, where C. is the cross product of vectors which are incident at vertex i. Case 2: Counter-clockwise If C> 0, then vertex i is negative. i If C.< 0, then vertex i is positive. If the polygon generation method discussed in Section 2-1 is used, the order of the sequence of line segments composing a polygon can not "be known beforehand. This is determined by RING. However, since the vertices which have the coordinates of XMIN, XMAX, YMIN or YMAX must be positive, we can easily find the direction, clockwise or counter- clockwise, when a cross product is computed. Figure 11. Polygon Decomposition A concave polygon can be decomposed into convex polygons by the following steps : 1) Determine the negative vertices. 2) Choose an arbitrary vertex V . Start with the vertex V_ and continue around the polygon until a negative vertex is reached. Extend the line segment having the negative vertex as an end-point until it intersects either another line segment or an extended line. 3) Continue around the polygon until the vertex V n is reached by applying the same procedure as Step 2. 17 It is necessary to prove that this method works. Proof: The method as described does not produce anything by some extended line segments, Figure 12. Definition: A set of polygons covers a polygon A if 1) there do not exist i, j such that for B., B. € B i J B. and B. overlap. 2) U B. = A l l Suppose that a polygon A with a covering B is such that the sum of the numbers of negative vertices of each B.£B is smaller than N. A covering B' of A can be constructed such that the total number of negative vertices in each B'.eB. is smaller than N-l in the following way. Select any negative point N and the line segments associated with N. The extension of one of the line segments intersects either l) the line segment I of some polygon of B or 2) the vertex of some polygon of B. Case 1 Figure 13* Call d the point of intersection. Let a and b be any two points on £. Since angle (adN) < 7T radians and angle (bdN) < 7T radians, d is not a new negative point. This is illustrated in Figure 13 above. Case 2: Let the intersected vertex be called d. Let a and b be two points, one on each side of d. Case 2a: angle (adb) < ir radian Figure ik. Since angle (adN) + angle (bdN) = angle (adb) angle (adb) > ir radians Figure 15 . Since d is already a negative pointy it need only be shown that it is not the case that the angles of both (adN) and (bdN) are greater than ir radians. This is clear , however, since their sum is less than 2rr radians. It is seen that a new negative vertex is not generated by extending a line segment having a negative vertex. It must now be shown that after the line segment is extended, that N is not a negative vertex of some polygon of B. Figure 16 • Let a and b be points on the line segments associated with N. It is known that angle (aNb) < 2tt radians. Since angle (aNd) + angle (bNd) = angle (aNb) < 2w radians, and since one is exactly ir radians, the other must be less than tt radians. QED Thus, a concave polygon can be decomposed into con ..Lygons for which propositional equations can be easily determined as shown above . Let A and B. be propositional equations for a concave poly- gon and decomposed convex polygons (i = 1, 2, ..., n), respectively. n A = U B, B. = l\ A l\ A...Ai. X 1 1 2 k where HJt is the k-th line of the i-th decomposed convex polygon. The K. set of points which lies in the oncave polygon A can be completely specified by Equation 2. According to the decomposition of a concave polygon, the polygon block of the data structure is modified as follows: POINTER 1 Name POINTER 2 1 1 p i -N 2 k P 2 5 3 8 P 3 h 11 7 k J *» 5 20 P 5 6 6 2k P 6 7 7 27 P 7 5 Original polygons Decomposed polygons J Figure 17 < 21 Where POINTER 1 chains to the line block and POINTER 2 denotes which polygons are concave: if P0INTER2[m] = polygon P is convex m if P0INTER2[m] \ polygon P is concave if P0INTER2[m] = n, n points to the address in which decom- posed convex polygons are in a ring. In order to determine the hidden line relationship between two polygons, consider the following three cases . Case 1: Both polygons are convex Step 1. Select one of the polygons arbitrarily as the primary. Step 2. Pick a line segment of the other polygon and deter- mine whether or not it intersects a line segment of the primary. If not, determine whether or not it lies in the primary. Step 3- Apply the same procedure as described in Step 2 until all line segments of the secondary are checked. Case 2: One polygon is convex (P ) and the other is concave (P p ) Step 1. The concave polygon (P p ) is decomposed into convex polygons v\ (i = 1, 2, ..., n). Step 2. Apply the same procedure described in Case 1 between P and P* (i = 1, 2, . . ., n) until all P_ are tested. Case 3: Both polygons are concave (P , P ) Step 1. Both polygons are decomposed into P (i « 1, 2, ..., n. and P£ (J = 1, 2, ..., m). Step 2. Apply the same steps as described in Case 1 until n X m tests are completed. Thus a relationship between the line segments of any two polygons (as defined in Section 2.2.1) can easily be determined. Once the relationship between every pair of polygons is determined, the hidden line problem of a picture consisting of polyhedra can easily be solved. This is discussed in detail in Chapter h. 2.2-3 Reduction of Computation Time Suppose there are n polygons of which m are concave. Let each concave polygon be decomposed into £. (i = 1, 2, . . . , m) convex polygons. The number N of tests required between any two polygons is described by the following equations: m N^n-m+Zi. i ... .3 N T ~ N C 2 ~ ^ (i. C 2J where ^C. = ki/(k - j)I jJ Figure 18 shows polygons 1, 2, 3, and k as convex and polygon 5 as concave with two negative vertices. 23 N=5-l+3=7 N T = 21 - 3 = 18 Therefore, 18 comparisons are required. However, if the picture is divided in the center as shown in Figure 18 (d, or d ), computation time may be reduced. ! d i Y \ 1 \ < 2 Y 1 \\ 5_\ 3 \ / t ^ > X Figure 18. Suppose n and n are the number of polygons in the sub space 1 and 2, respectively, and sub space 1 and 2 contain n^ (i^ > n^) and m^ (n > D concave polygons, respectively. Let each concave be decomposed into I (i = 1, 2, m ) or £ (j = 1, 2, . . DL ) . The total number o>2 comparisons, N , is then described by the following equations: m M i = n i- m i + . z 1 l i i=l l ™2 i N = n - m + Z t 2 0=1 m l T l - ^2 " .f x ^ C 2 nu T 2 = N 2 C 2 " Z =1 l\ °2 N T = T l + T 2 " q C 2 > ...1* where q is the number of common polygons in both sub spaces Considering the above example, if we use division line cL , as shown in Figure 18, the total number of comparisons, N , can be computed. N 2 = 3, N 2 -3-1 + 3=5 T l = 3 C 2 = 3 T, = 5 C 2 - 3 C 2 = 10 - 3 = 7 N^ = 3 + 7 = 10 Thus, the number of comparisons can be reduced from 18 to 10. However, the total number of comparisons cannot be reduced if d p is used. 25 The next problem is how to divide the picture in order to reduce the number of comparisons between two polygons. - - - J YMA.X _YMIN XMAX 19A 19B Figures 19A and 19B. Definition XMIN, XMAX, YMIN and YMAX are defined to be the minimum and the maximum of the X axis and the Y axis on the two-dimensional view plane ( shown in Figure I9B ) . The picture can be divided either by lines parallel to the Y axis or by lines parallel to the X axis. One of them has to be selected according to the amount of time saved. The optimal dimension method is described in the following steps: Step 1. Select a division line such that it does not intersect any polygon and such that there exists at least one polygon in 26 both subspaces. (Let n, and n p be the number of polygons in each sub space. ) Step 2. Select a line for each subspace such that it intersects less than n, - 2 or n p - 2 different polygons, respectively, and such that there exists at least one complete (not partial) polygon in both sub -sub spaces. Step 3» Apply Step 2 until there exists no such line. The selection of such a division line can be done systematically by using the XMIN, XMAX or the YMIN, YMAX of each polygon. Considering the example shown in Figure 19, if no division is applied, 20 (N = 7> N = 7C p - 2C p =20) comparisons are needed. However, if a division such as D , D is applied, only 7 (T, =1, T = 1, T_ = 5) comparisons are needed 27 3. THREE-DIMENSIONAL OBJECTS WITH CURVED SURFACES Triangles have "been used to describe a curved surface; for example, it is easily seen that it is impossible to completely cover the surface of a sphere with quadrangles. However, it can be done quite conveniently with triangles (Figure 20). Any surface can be approximated to arbitrary accuracy with small, but finite, triangles. Figure 20. Approximating a Cylinder by Planar Triangles As mentioned in Chapter 2, it is desirable to get the rela- tionship between any two curved surfaces, or between a curved surface and a polygon. Since any surface can be approximated with "triangles, the object and its perspective projection on a view plane are examined by the following method. 3.1 The Method to Determine the Relationship Between Two Curved Surfaces There may be a number (0 to 6) associated with each point, depending on where it is relative to the triangle, as shown in Figure 21. Figure 21 • For a line of the triangle in the surface, there exists a difference number such that for all i D. - K(V. +1 ) - M(V.) where N(V.) is a number which is assigned to the i-th vertex. A mapping is then defined from a set A to a set B such that A = { 0, 1, 2, 3, h, 5, 6 } B = { -3, -2, -1, 0, 1, 2, 3 } 29 E > +1 ► +1 + 2 ► +2 + 3 _ ^ + 3 + 4 ► +2 + 5 ► tl + 6 ► +3 The relationship between any two surfaces is determined by the following steps: i) Select one of them as the primary surface, ii) Select a triangle of the primary surface, iii) To each area of the triangle, assign a number (0 to 6). iv) Select a triangle of the secondary surface, v) Assign a number (0 to 6) to each vertex of the secondary triangle, vi) Compute the difference by the Equation 5 and map it onto B. The relationship can then be determined in the following way: 1) If N(V. ) for all i are "0", the primary is enclosing the secondary. 2) If N(V.) is "0" and N(V._ 1 ) or N(V. +1 ) is not "0", they intersect each other. 3) p. is "0" for all i '► no intersection h) JD. I is "1" for all i ■► no intersection 5) Id. I is "2" and N(V. ) is even =► no intersection li| i |D. I is "2" and N(V. ) is odd ►further test required | i I v i 6) JD. I i s "3" ► further test required Further Tests Case 1: where D. = 2 and N(V.) is odd Figure 22. It is necessary to check whether or not the line segment of the secondary surface, having a difference of 2, intersects the primary triangle, i.e., whether it is a) or b), as shown in Figure 22. b. Figure 23 . © is an additional vertex Considering the example in which to each vertex of polygon A and polygon B is assigned the same number, as shown in Figure 23, it is necessary to check whether or not the line segment having the difference 3 31 intersects the primary surface. However, in the example shown in Figure 23, polygon A is enclosing the primary, and polygon B and the primary have the relationship c}". In order to overcome this difficulty, it is necessary to divide the line having the difference 3 into two pieces, each of which has the difference 1 or 2. Thus the additional vertex must "be added on the line which has the difference 3- If there is no intersection, then the sums of all differences of the secondary are examined in order to distinguish the relationship a) from c) Consider the example shown in Figure 23- A. 1) N(a 2 ) - N( ai ) = 2 - 6=^-2 2) N(a 3 ) N(a 2 ) 3) N(a u ) - N(a 3 ) *0 N( a] _) - H%) k - p ► ? 5 - k=> 1 6 - 5 ►! sum No intersection because N(a p ) is even. No intersection. No intersection. No intersection. B. 1) N(b 2 ) 2) N(b 3 ) 3) N(b^) *0 N(b x ) N(b x ) = 2 - 3=^-1 = k - 2 fr -2 = 5 - hz=*l ■ N(b,,) = 3 - 5=#-2 N(b 2 ) N(b 3 ) V No intersection. No intersection. No intersection. Further test required. sum If the line segment having vertices b. and b, does not intersect the pri- mary by the further test, it is necessary to distinguish the secondary A from the secondary B. If the sum of the differences is 0, then they have the relationship c); if it is non-zero, then the secondary is enclosing the primary, relationship a) . By applying the above procedure until all triangles of the prir. and the secondary surfaces are exhausted, the relationship between them can be determined. It can easily be seen that the computation time grows very rapidly if curved surfaces are processed. Numbering scheme of the primary triangle Suppose V is a vertex having the largest y coordinate. Let H and I be lines having a vertex V , and a, and a be the slope of i. and JL, respectively. Figure 2k . Case a: a, < 0, a_ > or a 1 > 0, a p < Suppose a, is positive and given a point P: P > X P > i 1 > / 2 =>>. P > I ■3 'j 33 P > $ P > I > 1 p5 P < i P > h) P<8 3 V *6 If the number 1 is assigned, each number can automatically be assigned to the area by reversing the inequality sign from i, to jL in the end-around form and shifting the equality sign from 1-. to iL in a similar manner. Case b : a, , a > P > i x P > I, >1 P < i- P > J, *>2 P > /.. P > £. P < £- P < A P>* 3 ♦•3 P < A 1 p < ^ V >h p > / P < i P < j?-. l 2 *5 p > a i P > L P < £. ■v *6 Case c: a, , a < p > n x p > I. V *1 "\ P < P,. P > 9, r P>*3 P < i- P < ^ P > $. *3 P < i x P < t P < i. *U P > i- P < ^ *5 P > i 1 P>i 2 ) P < i, 4/ *6 35 k. HIDDEN LINE ELIMINATION U.l Local Hidden Line Elimination All coefficients (a, b, c) of the plane defined by Equation 6 must be computed for each polygon. z=ax+by + c 6 If the three coordinates (x, y, z) are given for each of three vertices, then a, b, and c can be computed by substituting each set of vertex coordinates into Equation 6 and solving the resulting system of three equations in three unknowns. Once the relationship between two polygons is determined by the preceding technique, the hidden line problem can easily be solved in the following way. Case 1: Relationship a). a) Compute the depths z defined by Equation 6 at all vertices of the enclosed polygon. b) If the depths of the vertices of the enclosing polygon are smaller than those of the enclosed polygon, all line segments of the enclosed polygon are hidden. c) If the depths of the vertices of the enclosing polygon are greater than those of the enclosed polygon, there is no hidden line. (The case in which some depths of the vertices of the enclosing polygon are greater than those of the enclosed polygon does not occur since the polygon generation method (described in the preceding section) is used. <§> Figure 25. Case 1 Case 2: Relationship b). a) Determine all vertices of the polygon A, formed by the intersection of the two polygons P. and P p (shaded area in Figure 26). Figure 26 . b) Compute the depths of P., and P at the vertices of A. c) If for each vertex of A the depth of P. is less than the depth of P ', line segments between V, and V_, V, and V are hidden. d) If for each vertex of A the depth of P, is greater than the depth of F ' , line segments between V and V , V~ and V. , V. and V are hidden. 37 Case 3* Relationship c). In the case of Relationship c), no hidden line can occur. Similarly, for curved surfaces which are decomposed into planar triangles, the hidden line problem can be solved from the relationships between triangles. k.2 Global Hidden Line Elimination Once the local hidden line problem is solved for each polyhedron, polygons consisting of all visible lines for each polyhedron can be determined. Looking again at Figure 6, polyhedron I has three polygons (A, B, C) which consist of all visible lines. Polyhedron II has two such polygons (D, E) . It is desired to determine the relationships between A, B, and C and D and E. The hidden line problem can be solved by the same procedure as that described above. 5. EXAMPLE AND RESULT ON B5500 The simple picture shown in Figure 27 is used for testing the algorithm. This picture is projected on a view plane and seen from an 9 infinite viewpoint, n This program can handle data to which an arbitrary transformation (such as a perspective transformation) has been applied. The picture above consists of four polygons, one of which is concave. Polygon 2 has been decomposed into polygons 5 and 6 by means of the dotted line which was obtained by extending the line between vertices 9 an ^ L 18. Real coordinates (x, y, z) of all vertices are shown in Figure 28 which is called the "point block" of the data structure. The "polygon block" is shown in Figure 29. If PN[i] = 0, then polygon i is convex. If PN[i] = N, then polygon i is concave and N points to the address of the first polygon in a ring of polygons where the successor of an element k of the ring is PN[k] . The elements of this ring are the result of decomposing the original polygon i. 39 P*TNT RLHCK Y Y 7 1 10.o 8.0 5.0 7 1 3 . o 7 \ 5.0 3 PO.O 7jo Ift.O 4 91.0 13.0 1'.1 5 15.0 16*. 9.7 6 9.0 1?'. o 15.0 7 ??.o 16.0 15.0 8 13.0 ??.o 10.0 9 ?6.o ?6.0 10.0 10 i4.o ii.n n.o 11 14.0 8.0 n.o 1? 1S.0 7 '.0 13.0 13 17.0 11.0 13.0 14 33. o 17.0 5.0 15 36.0 10.0 "5.0 16 44.0 14.0 10.0 17 41.0 91.0 10.0 18 16.0 15.0 1«.5 19 15.0 1 3> 15.0 Figure 28. 1+0 o •» cv o iri»i •- w* f\ c it «r c -*>o o *n -i oo mcvi o k(\j cm • • • • « • cv. c m tr, © c i (v -« — cvj cv I a a «h cv o o cv u*< it o c c c c e I II cv o c k < ir (V ID O 9 «c O cv k c. .- n* *. »r «~ c ir — «~ c C C C c c « o c c c c c 2 ■••••• > >e - Cv CV K C o CV « o o o o o o O CV CV ■ «- «y CV »- c (Z 2 »- © c c © © c cr > cc o cir a > C 2 C if C C « if a a. •- f < ■*■ f o c *- cv er o in «c a Figure 29 1+1 I IMF Rl ncK Cwy 1 2 3 4 5 n 6 7 8 n 9 10 n 1 1 1? 13 14 1 15 16 17 18 19 o 90 91 n 92 93 1 94 o 95 o JT 1 POINT? PTNG Lc HIO 1 ? 2 ? 3 ft 6 7 5 * 4 7 7 9 9 10 11 10 9 «s 4 a s 1 1 a 9 8 l? 1 1 1? 21 1 9 14 15 15 1 8 6 7 a 9 18 14 1 1 A 19 18 A 2 IS 16 16 1 If 17 17 A 17 t4 1 1 A 19 7 ?o 1 1 a 19 23 1 1 7 9 n 1 IP 13 29 1 9 1 ^ 10 A A 2 19 18 24 1 7 1ft 8 25 A 1 A 6 19 Figure 30- k2 In this example, since the data consists of four original polygons, polygons whose addresses are greater than h are all elements of decomposed polygons. P0LGN[i] is a pointer which points to the address i of the line block which contains the line segments of polygon i. XMIN, XMAX, YMIN and YMAX are defined in Section 2.2. AA, BB and CC are the coefficients of each polygon- "Line block" is shown in Figure 30. {0 : line i which is in the original picture 1 : line i which is not in the original picture (extended line) P0INTl[i] and P0INT2[i] point to the addresses of the point block corresponding to the endpoints of line i. The polygon block is tied to a ring of lines which represent a polygon. RING[i] is the address of the line following line i in this ring. Occasionally two polygons may share a linej in this case, the shared line must be put in the line block twice. upper half-plane y j polygon half -plane Figure 31 « i+3 An infinite line j divides the space into subspaces, LG[j] denotes the half -plane in which the polygon containing line j is found. LG[j] = / 1 : the polygon containing line j in the upper half -plane of line j V otherwise HID[i] denotes whether or not line i is visible, partially visible, or invisible from a view point. line i is visible HID[i] 1 : line i is partially visible v. line i is invisible The parts of partially visible lines are completely specified by the table shown in Figure 32, where LN[i] denotes a line which is partially visible. Relationships between two polygons are shown in Figure 33 > where PG1 and PG2 denote two polygons, and REL denotes the following relationship REL = £ No intersection between the polygons specified PG1 and PG2 The two polygons have intersections The polygon specified by PG1 is enclosing the polygon specified by PG2. kk (V 9 «1 o o c *r * * tr, cm x> ~« «» m >- m o o cv «r « i") o> • • • • IT «T IT' f C^ v a f k -OMC t k r«^ #»■ • • . •„ • <© *. in •*> «- o o o o rv c c c c coco ir cir c • • • • •O- U" ^- iT a v > — o c c c >- o c o o c C c c o« oc ■ • • • • in c in r a a — c c o c >< o c o c c c c c c c c c • • • • * U"