A clipping algorithm for parabola segments against circular windows

A clipping algorithm for parabola segments against circular windows

ARTICLE IN PRESS Computers & Graphics 30 (2006) 540–560 www.elsevier.com/locate/cag Technical Section A clipping algorithm for parabola segments ag...

421KB Sizes 102 Downloads 271 Views

ARTICLE IN PRESS

Computers & Graphics 30 (2006) 540–560 www.elsevier.com/locate/cag

Technical Section

A clipping algorithm for parabola segments against circular windows$ Qingbiao Wua,, Xinxian Huangb,a, Yujuan Hana a

Department of Mathematics, Scientific and Engineering Computation research institute, Zhejiang University, Hangzhou 310028, Zhejiang, PR China b Department of Mathematics, Hangzhou Teachers College, Hangzhou 310012, Zhejiang, PR China

Abstract Parabola is one of the most essential geometric elements. This paper presents a clipping algorithm for parabola segments against circular windows. Making use of the geometric features of parabola segments and circular windows and the position relations between them, this method firstly rules out some parabola segments located outside the window, and then deals with the rest by intersection calculations. Because of the position analysis and the preprocessing method, this clipping algorithm is of great efficiency. r 2006 Elsevier Ltd. All rights reserved. Keywords: Clipping algorithm; Circular window; Parabola segment

1. Introduction It is desirable to display wanted parts of a photograph and hide unwanted parts. Clipping is the process of determining how much of a giving photograph lies within the boundaries of the display region. Line segment clipping with respect to a rectangular window is a basic operation in most graphics applications. There are many efficient clipping algorithms for line segments against rectangular windows, such as the classic Cohen–Sutherland algorithm [1], mid-point division algorithm[2] suited for implementations in hardware presented by Sproull and Sutherland, parameterization algorithm [3] presented by Liang Youdong and Barsky, recent Nicholl–Lee–Nicholl algorithm [4], ELC algorithm [5], FLC algorithm [6], etc. Among these algorithms, two main types of line clipping algorithms have been proposed (see [7–9]), namely the encoding approach (with Cohen–Sutherland algorithm as a representative) and the parametric approach (with Liang–Barsky parameterization algorithm as a representative). Today in most application cases, the clipping window is no longer a simple regular rectangle. Sometimes the clipping window is a polygon, a circle or an ellipse, and so on. Thus this paper describes an algorithm based on circular windows. An important application of circular windows is in the graphics and image processing software. For example, when we are processing a digital photograph, the clipping region may be a rectangle, a polygon, a circle, or an ellipse. Besides, the screen capture software is needed to process all kinds of windows, rectangular, circular, elliptical, etc. Recently, some line clipping algorithms against circular windows [10–14] have been presented. The implementation method of [10,11] is substituting the line segment parametric equation into the algebraic equation of the circular window without discriminating the case that the line does not intersect the circle. Shen et al. [12] utilizes the distance from the circle center to the line segment. This method analyzes the relative position of the line segment and the circle according to the perpendicular from the circle center to the line, ruling out the segment all outside the circular window. And when the segment intersects the circle, this algorithm gets the intersection points by the rotation vector method. The method of Cai et al. [13] is ruling out some line $

This work was supported by National Natural Science Foundation of China (no. 10471128).

Corresponding author.

E-mail addresses: [email protected] (Q. Wu), [email protected] (X. Huang). 0097-8493/$ - see front matter r 2006 Elsevier Ltd. All rights reserved. doi:10.1016/j.cag.2006.03.001

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

541

segments all outside the circular window using the position relation between the circular window and its outer tangent square, and then implementing the clipping using the presetted standardized intersection tables and the mapping method. The idea of Lu et al. [14] is applying multiple encoding techniques. Many efficient and improved clipping algorithms for line segments against circular windows have been presented [15–20]. The parabola is one of the most essential geometric elements. In the procedure of image processing and character generating, we often need to clip parabola segments against rectangular or circular windows. However, there is no special result about the clipping of parabola segments. This paper proposes a clipping algorithm for parabola segments against circular windows. Making use of the geometric features of parabola segments and circular windows as well as the position relations between them, this method preprocesses some parabola segments located outside the window, and then deals with the rest by intersection calculations. And finally, we can use some classic line generation algorithms to display each visible segment, such as mid-point generation algorithm, etc. Because of the position analysis and the preprocessing method, this clipping algorithm is of great efficiency. 2. Algorithm Assume that the center of the circular window is at the origin of the coordinate system, the equation of the circle is x2+y2 ¼ R2, and the equation of the parabola is y ¼ ax2+bx+c (a6¼0), and the parabola segment is located in [p,q], (poq) [see Fig. 1]. 2.1. Rapid preprocessing (1) If the parabola is wholly over the outer tangent square or wholly below it, the parabola segment must be outside the circular window and neednot be displayed. When the parabola is over the outer tangent square, the discriminant is b2 XR 4a when the parabola is below the outer tangent square, the discriminant is a40 and c 

ao0 and c 

b2 p  R. 4a

(2) If the considered parabola segment is wholly on the left of the outer tangent square or on the right of it, the segment must be outside the circular window and neednot be displayed. When the parabola segment is on the left of the outer tangent square, the discriminant is qp  R

y

Q

p q

0

x

P Fig. 1. The clipping of parabola segments against circular windows.

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

542

when the parabola segment is on the right of the outer tangent square, the discriminant is pXR. So, if the equation of the parabola or the values of its end points satisfy one of the above expressions, the parabola segment must be located outside the circular window and neednot be displayed. 2.2. Unification of all cases As we know, the opening direction of the parabola is upward or downward according to the sign of the coefficient a. Moreover, because of the different values of p and q, segments in the same parabola are different [see Fig. 2]. To simplify the algorithm, we can utilize the symmetry of the circular window and then can unify all kinds of cases into one case to discuss: increasing parabola segments located on the right of the symmetry axis. In the following discussion, we call this kind of case as the basic case. (1) a40. (i) If p and q are both located on the left of the symmetry axis of the parabola, i.e. qp  b=2a; we may convert this case into the basic case by the symmetry transformation relative to the y coordinate axis. After the conversion, the new parabola equation is y ¼ a0 x2 þ b0 x þ c0 ; a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼ q, q0 ¼ p. If the result obtained from the basic case is ‘‘no display is done’’, then accordingly we neednot display it. If the result obtained from the basic case is ‘‘display the parabola segment between A0 ðxA0 ; yA0 Þ and B0 ðxB0 ; yB0 Þ’’, then accordingly we should display the parabola segment between A(xA,yA) and B(xB,yB), where xA ¼ xA0 , yA ¼ yA0 , xB ¼ xB0 , yB ¼ yB0 . (ii) If p and q are both located on the right of the symmetry axis of the parabola, i.e. pX  b=2a; it is the basic case and so we neednot convert it. (iii) If p and q are discretely located on the two sides of the symmetry axis, i.e. po  b=2a; and q4  b=2a; we should deal with the left section and the right section, respectively. First, we convert the section on the left of the symmetry axis into the basic case. The new parabola equation is y ¼ a0 x2 þ b0 x þ c0 ; where a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼ b=2a, q0 ¼ p. If the result obtained from the basic case is ‘‘no display is done’’, then accordingly we neednot display it. If the result obtained from the basic case is ‘‘display the parabola segment between A0 ðxA0 ; yA0 Þ and B0 ðxB0 ; yB0 Þ’’, then accordingly we should display the parabola segment between AðxA ; yA Þ and BðxB ; yB Þ, where xA ¼ xA0 , yA ¼ yA0 , xB ¼ xB0 , yB ¼ yB0 . For the section on the right of the symmetry axis, we only convert the parameter p, p0 ¼ b=2a;, and the other parameters neednot be converted. And the result obtained from the basic case also neednot be converted. (2) ao0. Similarly to the above analysis, we can utilize the symmetry of the circular window and unify all kinds of cases into the basic case, a40, the increasing parabola segment located on the right of the symmetry axis (i) If p and q are both located on the left of the symmetry axis of the parabola, i.e. qp  b=2a;, we may convert this case into the case of a40 by the symmetry transformation relative to the x coordinate axis, as (i) in (1) above, and then convert it into the basic case as the above procedure. Synthesizing the two steps, we should make the conversion: a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼ q, q0 ¼ p. If the result obtained from the basic case is ‘‘no display is done’’, then accordingly we neednot display it. If the result obtained from the basic case is ‘‘display the parabola segment between A0 ðxA0 ; yA0 Þ and B0 ðxB0 ; yB0 Þ’’, then accordingly we should display the parabola segment between AðxA ; yA Þ and BðxB ; yB Þ, where xA ¼ xA0 , yA ¼ yA0 , xB ¼ xB0 , yB ¼ yB0 . (ii) If p and q are both located on the right of the symmetry axis of the parabola, i.e. pX  b=2a; we can make the symmetry transformation relative to the x coordinate axis and the result is the case (ii) in (1), i.e. the basic case. Therefore, we should make the conversion: a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼ p; q0 ¼ q. If the result obtained from the basic case is ‘‘no display is done’’, then accordingly we neednot display it. If the result obtained from the basic

Fig. 2. Different kinds of parabola segments.

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

543

case is ‘‘display the parabola segment between A0 ðxA0 ; yA0 Þ and B0 ðxB0 ; yB0 Þ’’, then accordingly we should display the parabola segment between AðxA ; yA Þ and BðxA ; yA Þ, where xA ¼ xA0 , yA ¼ yA0 , xB ¼ xB0 , yB ¼ yB0 . (iii) If p and q are discretely located on the two sides of the symmetry axis, i.e. po  b=2a and q4  b=2a; we should deal with the left section and the right section, respectively. First, we convert the section on the left of the symmetry axis into the basic case by making the conversion: a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼ b=2a, q0 ¼ p. If the result obtained from the basic case is ‘‘no display is done’’, then accordingly we neednot display it. If the result obtained from the basic case is ‘‘display the parabola segment between A0 ðxA0 ; yA0 Þ and B0 ðxB0 ; yB0 Þ’’, then accordingly we should display the parabola segment between A(xA,yA) and B(xB,yB), where xA ¼ xA0 , yA ¼ yA0 , xB ¼ xB0 , yB ¼ yB0 . For the section on the right of the symmetry axis, we should convert it into the basic case by the conversion: a0 ¼ a, b ¼ b, c0 ¼ c, p0 ¼ b=2a, q0 ¼ q. If the result obtained from the basic case is ‘‘no display is done’’, then accordingly we neednot display it. If the result obtained from the basic case is ‘‘display the parabola segment between A0 ðxA0 ; yA0 Þ and B0 ðxB0 ; yB0 Þ’’, then accordingly we should display the parabola segment between A(xA,yA) and B(xB,yB), where xA ¼ xA0 , yA ¼ yA0 , xB ¼ xB0 , yB ¼ yB0 . 0

2.3. Processing the basic case, a40, increasing parabola segments on the right of the symmetry axis According to the analysis in Section 2.2, we only need to discuss one kind of parabolasegments. The following is the analysis of the case, a40, increasing parabola segments on the right of the symmetry axis. Now, we suppose the parabola mentioned in the following satisfies this basic case. Let D denote the vertex point of the parabola, i.e. the extremal vertex. Let P denote the point in the parabola satisfying x ¼ p (the x coordinate is p) and Q be the point in the parabola satisfying x ¼ q [see Fig. 3]. Firstly, qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi jOPj ¼ ðap2 þ bp þ cÞ2 þ p2 ,   qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi OQ ¼ ðaq2 þ bq þ cÞ2 þ q2 ,

jODj ¼

qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 4b2 þ ð4ac  b2 Þ2 4a

.

According to the possible positions of the parabola’s vertex point, there are three cases to discuss: jODj ¼ R; jODjoR and jODj4R. Let xD denote the x coordinate of D and y denote the coordinate of D. Because we consider the right part of the parabola, the amount of intersection points of the circle and the parabola is no more than three. Let T0 denote the left intersection point, T2 denote the right intersection point, and T1 denote the middle intersection point.

y

p

q

x

0 Q

P D Fig. 3. A vertex point and two end points of the parabola segment.

ARTICLE IN PRESS 544

Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

L2 y Q

L1

P

Q P

D

D L3 L4 0

Q

Q

x T2

P P D

D

Fig. 4. The vertex point of the parabola on the circumference, Quadrant I, II, III.

y

L6 Q

T2

0

T1 D

L5 x

D

P

Fig. 5. The vertex point of the parabola on the circumference, Quadrant IV.

(1) jODj ¼ R. We analyze according to the quadrant in which the vertex point D is located. (i) Quadrant I ð0pxD pR; 0pyD pRÞ. In Quadrant I, because the parabola we consider is the right part and increases, the parabola segment must be outside the circular window when the vertex point is on the circumference, and therefore we neednot display it [see L1 in Fig. 4]. (ii) Quadrant II and III ðRpxD o0; RpyD pRÞ. The analysis of Quadrant III is similar to that of Quadrant II, so we discuss them together. A If jOPjXR, the parabola segment between P and Q must be outside the circular window according to the features  of  the parabola segment we discuss, and therefore neednot be displayed [see L2 in Fig. 4]. B If OQpR, the PQ parabola segment must be inside the circle, so we should display the whole parabola segment between P and Q [see L3 in Fig. 4].

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

y

545

L7

L8 Q P

Q

L9 Q

P

x

0 T2 P

Fig. 6. The vertex point of the parabola in the circle, Quadrant I,II,III.

y L12 Q

L11

T2

0

x P

L10

Q Q

P P

Fig. 7. The vertex point of the parabola in the circle, Quadrant IV, one intersection point.

  C Otherwise, jOPjoR and OQ4R, the parabola segment and the circle must intersect at another point than the vertex point. Calculate the intersection point T2 and display the parabola segment between P and T2 [see L4 in Fig. 4]. The calculation formulae of the intersection points T0, T1 and T2 are in Appendix A. (iii) Quadrant IV ð0px RpyD o0Þ.  D pR;  A jOPj4R and OQ4R, calculate T1 and T2. If T1 or T2 do not exist, or T1 ¼ T2, it is the situation that the parabola and the circle are separate or tangent except the vertex point, so no display is done [see L5 in Fig. 5]. If T16¼T2, it is the situation that the parabola and the circle intersect at other two different points than the vertex point.  If qoxT 1 , P and Q are located between D and T1. No display is done.  If p4xT 2 , P and Q are both located on the right of T2. No display is done.  If poxT 1 and q4xT 2 , P is located between D and T1, and Q is on the right of T2, so we should display the parabola segment between   T1 and T2 [see L6 in Fig. 5]. B If jOPj4R and OQ pR, calculate T1 and display the parabola segment between T1 and Q. 4R, calculate T2 and display the parabola segment between P and T2. C If jOPjpRand OQ   D If jOPjpR and OQpR, display the parabola segment between P and Q.

ARTICLE IN PRESS 546

Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

y L13

Q

x

0 T1(T2)

D P T0

Fig. 8. The vertex point of the parabola in the circle, Quadrant IV, two intersection points.

y L14

Q

T2

0

x

T1 D T0

P

Fig. 9. The vertex point of the parabola in the circle, Quadrant IV, three intersection points.

(2) jODjoR. According to the analyzed quadrant in which the vertex point D is located, the cases in Quadrant I,II,III are similar, so we analyze these three cases together. (i) Quadrant I, II, III ðRpxD p0Þ or ð0oxD pR; 0pyD pRÞ: A If jOPjXR, the parabola segment PQ must be outside the circle and no display is done [see L7 in Fig. 6].  B If OQpR, the parabola segment PQ must be inside of the circle and display the parabola segment between P and Q [see L8 in Fig. 6].   C Otherwise, jOPjoR and OQ4R, the parabola segment must intersect the circle at the point T2, and display the parabola sgment between P and T2 [see L9 in Fig. 6]. (ii) Quadrant IV ð0oxD pR; RpyD o0Þ. The situation of Quadrant IV is comparatively complex. Because in this case, the vertex point of the parabola is in the circle, it must intersect the circle at a point and then T2 must exist. There are three possible cases: One intersection point, i.e. T2 [see Fig. 7]; two intersection points: one is the intersection point and the other is the tangency point. So, T0 exists and T1 coincides with T2, T1 ¼ T2 [see Fig. 8]; three intersection points: T0, T1 and T2 all exist and do not coincide, T06¼T16¼T2 [see Fig. 9].

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

547

y L15

Q

T2 x

0

D P

T1

T0

Fig. 10. The vertex point of the parabola in the circle, Quadrant IV, three intersection points.

(I) One intersection point. A If jOPjXR, the parabola segment PQ must be outside the circle, and no display is done [see L10 in Fig. 7].  B If OQpR, the parabola segment PQ must be inside the circle, and display the parabola segment between P and Q [see L11 in Fig. 7].   C Otherwise, jOPjoR and OQ4R, the parabola segment must intersect the circle at T2, and display the parabola segment between P and T2 [see L12 in Fig. 7]. (II) Two intersection points. A If jOPjXR, the parabola segment PQ must be outside the circle, and no display is done.  B If OQpR, the parabola segment PQ must be inside the circle, and display the parabola segment between P and Q.   C Otherwise, jOPjoR and OQ4R, the parabola segment must intersect the circle at T0, and T1 coincides with T2. Furthermore, the parabola is tangent with the circle and T1(T2) is the tangency point. So display the parabola segment between P and T0 [see L13 in Fig. 8]. (III) Three intersection  points.  A jOPj4R and OQ4R, there are three cases  If qoxT 1 , P and Q are both located between D and T1, and no display is done.  If p4xT 2 , P and Q are both located on the right of T2, and no display is done.  If poxT 1 and q4xT 2 , P is located between T0 and T1, while Q is located on the right of T2 and display the parabola segment between  T 1 and T 2 [see L14 in Fig. 9]. B If jOPj4R and OQpR, P is located between T0 and T1, while Q is located between T1 and T2. Calculate T1 and display   the parabola segment between T1 and Q. C If jOPjpR and OQ4R, there are three cases:  If ppxT 0 and qoxT 1 , P is located between D and T0, while Q is located between T0 and T1. Display the parabola segment between P and T0.  If ppxT 0 and q4xT 2 , P is located between D and T0, while Q is located on the right of T2. Display the parabola segment between P and T0 and the segment between T1 and T2 [see L15 in Fig. 10].  If pXxT 1 and q4xT 2 , P is located between T1 and T2, while Q is located on the right of T2. Display the parabola segment between P andT2.  D If jOPjpR and OQpR, there are three cases:  If qpxT 0 , P and Q are both located between D and T0. Display the parabola segment between Pand Q.  If pXxT 1 , P and Q are both located between T1 and T2. Display the parabola segment between P and Q.  If ppxT 0 , and qXxT 1 , P is located between D and T0, while Q is located between T1 and T2. Display the parabola segment between P and T0 and the segment between T1 and Q [see L16 in Fig. 11].

ARTICLE IN PRESS 548

Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

y L16

0

x

T2 Q

T1

DP T0

Fig. 11. The vertex point of the parabola in the circle, Quadrant IV, three intersection points.

y

L17 L20

L18 T2

L19 Q

0

P

Q

x

T2

T1

T1 P

Fig. 12. The vertex point of the parabola outside the circle.

(3) jODj4R. We can discuss the cases in Quadrant II,III,IV together for the cases are similar (i) Quadrant I ð0pxD pR; 0pyD pRÞ. Clearly, according to the features of the parabola and the circle we discuss, the parabola segment and the circle cannot intersect and no display is done [See L17 in Fig. 12]. (ii) Quadrant II, III, IVðRpx D o0Þ or ð0pxD pR; RpyD o0Þ   A If jOPj4R and OQ4R, calculate T1 and T2.

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

549

Table 1 pXR or qp  R

No display is done.

2

a40 and c 

b XR 4a

ao0 and c 

b2 pR 4a

a40

b 2a b pX 2a b b and q4 po 2a 2a

qp

a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼ q, q0 ¼ p No conversion is done. The left part:a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼ The right part:p0 ¼

a40

b 2a b pX 2a b b and q4 po 2a 2a

qp

The basic case

b 0 , q ¼ p 2a

b 2a

a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼ q, q0 ¼ p a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼ p, q0 ¼ q b 0 , q ¼ p 2a b 0 ,q ¼q The right part: a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼ 2a The left part: a0 ¼ a, b0 ¼ b, c0 ¼ c, p0 ¼

Table 2 a40

b qp 2a b pX 2a b b and q4 po 2a 2a

xA ¼ xA0 ; yA ¼ yA0 , xB ¼ xB0 , yB ¼ yB0 No conversion is done. The left part: xA ¼ xA0 ; yA ¼ yA0 , xB ¼ xB0 , yB ¼ yB0 . The right part: No conversion is done.

ao0

b qp 2a b pX 2a b b and q4 po 2a 2a

xA ¼ xA0 ;, yA ¼ yA0 ; xB ¼ xB0 , yB ¼ yB0 xA ¼ xA0 , yA ¼ yA0 ; xB ¼ xB0 , yB ¼ yB0 The left part: xA ¼ xA0 ; yA ¼ yA0 ; xB ¼ xB0 , yB ¼ yB0 The right part: xA ¼ xA0 , yA ¼ yA0 ; xB ¼ xB0 , yB ¼ yB0

If T1 or T2 do not exist, or T1 ¼ T2, the parabola and the circle are separate or tangent. No display is done [see L18 in Fig. 12].  If T16¼T2, the parabola and the circle must intersect at two points except the vertex point:  If qoxT 1 , P and Q are both located between D and T1 and no display is done.  If p4xT 2 , P and Q are both located on the right of T2 and no display is done.  If poxT 1 and q4xT 2 , P is located between D and T1, while Q is located on the right of T2. Display the parabola segment between T1 and T2 [see L19 in Fig. 12]. B If jOPj4R and OQpR, calculate T1 and display the parabola segment between T1 and Q [see L20 in Fig. 12].   C If jOPjpR and OQ 4R, calculate T2 and display the parabola segment between P and T2. D If jOPjpR and OQpR, display the parabola segment between P and Q. Now, we have finished discussing all cases in the clipping algorithm. According to the above analysis, we can use two tables grouping the possible cases and the associated actions. Table 1 is the classification and preprocessing procedure, ruling out some segments outside the circle and unifying all cases into the basic case. Table 2 processes the results obtained from the basic case.

ARTICLE IN PRESS 550

Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

And we use a tree structure grouping the possible cases and the associated actions in the processing of the basic case.

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

551

3. Overall algorithm structure Appendix B is the overall algorithm structure. 4. The example In this section, we apply the clipping algorithm for parabola segments against circular windows and show one example. Example 1. We apply the clipping algorithm for parabola segments against circular windows in the medical image system that is called Picture Archiving and Communication System (PACS). In PACS medical diagnoses function, We need locally

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

552

Fig. 13. The clipping algorithm for parabola segments against circular windows in PACS.

zoom in the picture of CT and CR Which the function is named with magnifying glass. In CT and CR pictures, some characteristic lines and the measure lines are parabola segments. The window of the magnifying glass is circular. We applied the clipping algorithm for parabola segments against circular windows in PACS (see Fig. 13). 5. Conclusion This paper proposes a clipping algorithm for parabola segments against circular windows. Making use of the geometric features of parabola segments and circular windows and the position relations between them, this method preprocesses some parabola segments located outside the window, and then deals with the rest by intersection calculations. Because of the position analysis and the preprocessing method, this clipping algorithm is efficient and with higher speed. Furthermore, the algorithm in this paper has practical value for both the clipping of parabola segments against rectangular windows and the clipping for common monotone function curves. Appendix A The following are the calculation formulae for the x coordinates of the intersection points of the parabola and the circle. And the y coordinates are obtained by substituting the x coordinates into the parabola equations. Let E ¼ 1 þ b4 þ 4ac þ b2 ð2  8acÞ þ 4a2 ð4c2  3r2 Þ, F ¼ 3b2 ð1  2ac þ 2a2 ð8c2  3r2 ÞÞ, A¼

qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 4E 3 þ 4ðb6 þ b4 ð3  12acÞ  ð1 þ 2acÞð1  4ac þ 4a2 ð8c2  9r2 ÞÞ þ F Þ2 ,

B ¼ 2 þ 2b6 þ 12ac þ b4 ð6  24acÞ þ a2 ð48c2 þ 72r2 Þ  16a3 ð8c3  9cr2 Þ þ 2F þ A, C ¼ 21=3 a2 E, sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 6b2 4ð1 þ b2 þ 2acÞ 2C 1 D¼  þ 4 þ 2 22=3 B. a2 aB a a2 Then xT 0

0 sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi pffiffiffi 1 pffiffiffi 1 @ 2b2 4ð1 þ b2 þ 4acÞ C B 2 6bA 6b þ 6aD þ 6a , ¼   4  1=3  3 12a 3a2 3a B 2 3a2 aD a2

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

xT 1

xT 2

553

0 sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi pffiffiffi 1 pffiffiffi 1 @ 2b2 4ð1 þ b2 þ 4acÞ C B 2 6bA 6b þ 6aD  6a , ¼   4  1=3 þ 3 12a 3a2 3a B 2 3a2 aD a2 0 sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi pffiffiffi 1 pffiffiffi 1 @ 2b2 4ð1 þ b2 þ 4acÞ C B 2 6bA 6b þ 6aD þ 6a . ¼   4  1=3 þ 3 12a 3a2 3a B 2 3a2 aD a2

Appendix B B.1. Define global variables int point; /* The value of ‘‘point’’ indicates the amount of the parabola segments to be displayed. The value 0 means that no segment should be displayed; the value 2 means that one segment should be displayed; the value 4 means that two segments should be displayed. */ float xh, yh, xi, yi, xj, yj, xk, yk; /* ‘‘xh’’, ‘‘yh’’, ‘‘xi’’, ‘‘yi’’, ‘‘xj’’, ‘‘yj’’, ‘‘xk’’, ‘‘yk’’ indicate the coordinates of the end points of the parabola segments to be displayed. */ B.2. MAIN_PROCEDURE MAIN_PROCEDURE is a classification and preprocessing procedure, getting the equations of the circle and the parabola segment, classifying them as a particular case according to their relative position, and converting this case to the basic case by altering the initial parameters. MAIN_PROCEDURE ( ) Step 1: Step 2:

Step 3:

Step 4:

Get a, b, and c, the coefficients of the parabola, p and q, the abscissa values of the end points, r, the radius of the circle. If a40 and cb*b/4/a 4 ¼ r Go to step11; If ao0 and cb*b/4/a o ¼ r Go to step11; If p 4 ¼ r Go to step11; If q o ¼ r Go to step11; If a40 and q o ¼ b/2/a a1 ¼ a; b1 ¼ b; c1 ¼ c; p1 ¼ q; q1 ¼ p; /* transformation formulae */ Call BASIC_PROCEDURE ( a1, b1, c1, p1, q1, r ); If point ¼ ¼ 0 Go to step 11; If point ¼ ¼ 2 xh ¼ xh; xi ¼ xi; DISPLAY(xh,yh,xi,yi); /* DISPLAY is any kind of line generation algorithm. ‘‘xh’’, ‘‘yh’’, ‘‘xi’’, ‘‘yi’’ indicate the coordinates of the end points of the parabola segments to be displayed. Here we do not provide a concrete algorithm. */ Go to step11; If point ¼ ¼ 4 xh ¼ xh; xi ¼ xi; xj ¼ xj; xk ¼ xk; DISPLAY(xh,yh,xi,yi); DISPLAY(xj,yj,xk,yk); Go to step 11; If a40 and p 4 ¼ b/2/a a1 ¼ a; b1 ¼ b; c1 ¼ c; p1 ¼ p; q1 ¼ q; Call BASIC_PROCEDURE ( a1, b1, c1, p1, q1, r ); If point ¼ ¼ 0 Go to step 11;

ARTICLE IN PRESS 554

Step 5:

Step 6:

Step 7:

Step 8:

Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

If point ¼ ¼ 2 DISPLAY(xh,yh,xi,yi); Go to step11; If point ¼ ¼ 4 DISPLAY(xh,yh,xi,yi); DISPLAY(xj,yj,xk,yk); Go to step 11; If a40 and po b/2/a and q 4b/2/a a1 ¼ a; b1 ¼ b; c1 ¼ c; p1 ¼ b/2/a; q1 ¼ p; Call BASIC_PROCEDURE ( a1, b1, c1, p1, q1, r ); If point ¼ ¼ 0 Go to step6; If point ¼ ¼ 2 xh ¼ xh; xi ¼ xi; DISPLAY(xh,yh,xi,yi); Go to step6; If point ¼ ¼ 4 xh ¼ xh; xi ¼ xi; xj ¼ xj; xk ¼ xk; DISPLAY(xh,yh,xi,yi); DISPLAY(xj,yj,xk,yk); Go to step6; If a40 and po-b/2/a and q 4b/2/a a1 ¼ a; b1 ¼ b; c1 ¼ c; p1 ¼ b/2/a; q1 ¼ q; Call BASIC_PROCEDURE (a1, b1, c1, p1, q1, r); If point ¼ ¼ 0 Go to step11; If point ¼ ¼ 2 DISPLAY(xh,yh,xi,yi); Go to step11; If point ¼ ¼ 4 DISPLAY(xh,yh,xi,yi); DISPLAY(xj,yj,xk,yk); Go to step11; If ao0 and q o ¼ b/2/a a1 ¼ a; b1 ¼ b; c1 ¼ c; p1 ¼ q; q1 ¼ p; Call BASIC_PROCEDURE ( a1, b1, c1, p1, q1, r );If point ¼ ¼ 0 Call BASIC_PROCEDURE ( a1, b1, c1, p1, q1, r ); If point ¼ ¼ 0 Go to step11; If point ¼ ¼ 2 xh ¼ xh; yh ¼ yh; xi ¼ xi; yi ¼ yi; DISPLAY(xh,yh,xi,yi); Go to step11; If point ¼ ¼ 4 xh ¼ xh; yh ¼ yh; xi ¼ xi; yi ¼ yi; xj ¼ xj; yj ¼ yj; xk ¼ xk; yk ¼ yk; DISPLAY(xh,yh,xi,yi); DISPLAY(xj,yj,xk,yk); Go to step11; If ao0 and p 4 ¼ b/2/a a1 ¼ a; b1 ¼ b; c1 ¼ c; p1 ¼ p; q1 ¼ q; Call BASIC_PROCEDURE ( a1, b1, c1, p1, q1, r ); If point ¼ ¼ 0 Go to step11; If point ¼ ¼ 2 yh ¼ yh; yi ¼ yi; DISPLAY(xh,yh,xi,yi); Go to step11; If point ¼ ¼ 4 yh ¼ yh; yi ¼ yi; yj ¼ yj; yk ¼ yk; DISPLAY(xh,yh,xi,yi); DISPLAY(xj,yj,xk,yk); Go to step11;

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

Step 9:

Step 10:

Step 11:

555

If ao0 and pob/2/a and q4b/2/a a1 ¼ a; b1 ¼ b; c1 ¼ c; p1 ¼ b/2/a; q1 ¼ p; Call BASIC_PROCEDURE ( a1, b1, c1, p1, q1, r ); If point ¼ ¼ 0 Go to step10; If point ¼ ¼ 2 xh ¼ xh; yh ¼ yh; xi ¼ xi; yi ¼ yi; DISPLAY(xh,yh,xi,yi); Go to step10; If point ¼ ¼ 4 xh ¼ xh; yh ¼ yh; xi ¼ xi; yi ¼ yi; xj ¼ xj; yj ¼ yj; xk ¼ xk; yk ¼ yk; DISPLAY(xh,yh,xi,yi); DISPLAY(xj,yj,xk,yk); Go to step10; If ao0 and pob/2/a and q 4b/2/a a1 ¼ a; b1 ¼ b; c1 ¼ c; p1 ¼ b/2/a; q1 ¼ q; Call BASIC_PROCEDURE ( a1, b1, c1, p1, q1, r ); If point ¼ ¼ 0 Go to step11; If point ¼ ¼ 2 yh ¼ yh; yi ¼ yi; DISPLAY(xh,yh,xi,yi); Go to step11; If point ¼ ¼ 4 yh ¼ yh; yi ¼ yi; yj ¼ yj; yk ¼ yk; DISPLAY(xh,yh,xi,yi); DISPLAY(xj,yj,xk,yk); Go to step11; Stop.

B.2.1. BASIC_PROCEDURE BASIC_PROCEDURE calls the corresponding sub_procedure according to the distance between the circle center and the vertex point of the parabola. BASIC_PROCEDURE (a, b, c, p, q, r) Step 1: Calculate the vertex point D of the parabola: xd ¼ b/2/a; yd ¼ cb*b/4/a; Step 2: Calculate the distance between O and P: op ¼ sqrt (pow (a*p*p+b*p+c, 2)+p*p); Calculate the distance between O and Q: oq ¼ sqrt (pow (a*q*q+b*q+c, 2)+q*q) Calculate the distance between O and D: od ¼ sqrt (4*b*b+(4*a*cb*b)* (4*a*cb*b))/4/a; Step 3: If od ¼ ¼ r Call SUB_PROCEDURE1 (a, b, c, p, q, r, xd, yd, op, oq); Go to Step6; Step 4: If odor Call SUB_PROCEDURE2 (a, b, c, p, q, r, xd, yd, op, oq); Go to Step6; Step 5: If od4r Call SUB_PROCEDURE3 (a, b, c, p, q, r, xd, yd, op, oq); Step 6: Return.

B.2.2. SUB_PROCEDURE1 SUB_PROCEDURE1 processes the case that the vertex point is on the circumference. SUB_PROCEDURE1 (a, b, c, p, q, r, xd, yd, op, oq)

ARTICLE IN PRESS 556

Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

Step 1: If 0 o ¼ xd o ¼ r and 0 o ¼ yd o ¼ r point ¼ 0; Return; Step 2: If r o ¼ xdo0 and r o ¼ yd o ¼ r If op 4 ¼ r point ¼ 0; Return; If oq o ¼ r Calculate the coordinates of P and Q: xp ¼ p; yp ¼ a*p*p+b*p+c; xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xq; yi ¼ yq; Return; Else Calculate the coordinates of P: xp ¼ p; yp ¼ a*p*p+b*p+c; Calculate the coordinates of the intersection point T2 (xt2, yt2); /* The calculation formulae of the intersection points T0, T1, T2 are in Appendix A.*/ point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xt2; yi ¼ yt2; Return; Step 3: Else If op4r and oq4r Calculate the intersection points T1 (xt1, yt1 ) and T2 (xt2, yt2 ) in Appendix A; If xt1 or xt2 do not exit or xt1 ¼ ¼ xt2 point ¼ 0; Return; Else If p4xt2 or qoxt1 point ¼ 0; Return; If poxt1 and q 4xt2 point ¼ 2; xh ¼ xt1; yh ¼ yt1; xi ¼ xt2; yi ¼ yt2; Return; If op 4r and oq o ¼ r Calculate the intersection point T1 (xt1, yt1) in Appendix A; Calculate the coordinates of Q: xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 2; xh ¼ xt1; yh ¼ yt1; xi ¼ xq; yi ¼ yq; Return; If op o ¼ r and oq4r Calculate the coordinates of P; xp ¼ p; yp ¼ a*p*p+b*p+c; Calculate the intersection point T2 (xt2, yt2 ) in Appendix A; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xt2; yi ¼ yt2; Return; Else Calculate the coordinates of P and Q: xp ¼ p; yp ¼ a*p*p+b*p+c; xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xq; yi ¼ yq; Return;

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

B.2.3. SUB_PROCEDURE2 SUB_PROCEDURE 2 processes the case that the vertex point is inside the circle. SUB_PROCEDURE 2 (a, b, c, p, q, r, xd, yd, op, oq) Step 1: If r o ¼ xd o ¼ 0 or ( 0oxd o ¼ r and 0 o ¼ yd o ¼ r) If op4 ¼ r point ¼ 0; Return ; If oq o ¼ r Calculate P and Q: xp ¼ p; yp ¼ a*p*p+b*p+c; xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xq; yi ¼ yq; Return; Else Calculate P: xp ¼ p; yp ¼ a*p*p+b*p+c; Calculate T2 in Appendix A; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xt2; yi ¼ yt2; Return; Step 2: Else Calculate T0, T1, and T2 in Appendix A; If xt0 or xt1 do not exist Go to step3; If xt1 ¼ ¼ xt2 Go to step4; If xt1! ¼ xt2 ! ¼ xt3 Go to step5; Step 3: If op 4 ¼ r point ¼ 0; Return; If oq o ¼ r Calculate P and Q: xp ¼ p; yp ¼ a*p*p+b*p+c; xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xq; yi ¼ yq; Return; Else Calculate P: xp ¼ p; yp ¼ a*p*p+b*p+c; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xt2; yi ¼ yt2; Return; Step 4: If op 4 ¼ r point ¼ 0; Return; If oq o ¼ r Calculate P and Q: xp ¼ p; yp ¼ a*p*p+b*p+c; xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xq; yi ¼ yq; Return; Else Calculate P: xp ¼ p; yp ¼ a*p*p+b*p+c; point ¼ 2;

557

ARTICLE IN PRESS 558

Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

xh ¼ xp; yh ¼ yp; xi ¼ xt0; yi ¼ yt0; Return; Step 5: If op4r and oq 4r If p4xt2 or qoxt1 point ¼ 0; Return; If poxt1 and q4xt2 point ¼ 2; xh ¼ xt1; yh ¼ yt1; xi ¼ xt2; yi ¼ yt2; Return; If op4r and oq o ¼ r Calculate Q: xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 2; xh ¼ xt1; yh ¼ yt1; xi ¼ xq; yi ¼ yq; Return; If op o ¼ r and oq 4r If p o ¼ xt0 and qoxt1 Calculate P: xp ¼ p; yp ¼ a*p*p+b*p+c; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xt0; yi ¼ yt0; Return; If p o ¼ xt0 and q4xt2 Calculate P: xp ¼ p; yp ¼ a*p*p+b*p+c; point ¼ 4; xh ¼ xp; yh ¼ yp; xi ¼ xt0; yi ¼ yt0; xj ¼ xt1; yj ¼ yt1; xk ¼ xt2; yk ¼ yt2; Return; If p 4 ¼ xt1 and q4xt2 Calculate P: xp ¼ p; yp ¼ a*p*p+b*p+c; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xt2; yi ¼ yt2; Return; Else If p 4 ¼ xt1 or q o ¼ xt0 Calculate P and Q: xp ¼ p; yp ¼ a*p*p+b*p+c; xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xq; yi ¼ yq; Return; If p o ¼ xt0 and q 4 ¼ xt1 Calculate P and Q: xp ¼ p; yp ¼ a*p*p+b*p+c; xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 4; xh ¼ xp; yh ¼ yp; xi ¼ xt0; yi ¼ yt0; xj ¼ xt1; yj ¼ yt1; xk ¼ xq; yk ¼ yq; Return;

B.2.4. SUB_PROCEDURE3 SUB_PROCEDURE3 processes the case that the vertex point is outside the circle. SUB_PROCEDURE3 (a, b, c, p, q, r, xd, yd, op, oq) Step 1:

If 0 o ¼ xd o ¼ r and 0 o ¼ yd o ¼ r point ¼ 0; Return;

ARTICLE IN PRESS Q. Wu et al. / Computers & Graphics 30 (2006) 540–560

Step 2:

559

Else If op4r and oq4r Calculate T1 and T2 in Appendix A; If xt1 or xt2 do not exist or xt1 ¼ ¼ xt2 point ¼ 0; Return; Else If p4xt2 or qoxt1 point ¼ 0; Return; If poxt1 or q4xt2 point ¼ 2; xh ¼ xt1; yh ¼ yt1; xi ¼ xt2; yi ¼ yt2; Return; If op4r and oq o ¼ r Calculate T1 in Appendix A; Calculate Q: xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 2; xh ¼ xt1; yh ¼ yt1; xi ¼ xq; yi ¼ yq; Return; If op o ¼ r and oq4r Calculate P: xp ¼ p; yp ¼ a*p*p+b*p+c; Calculate T2 in Appendix A; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xt2; yi ¼ yt2; Return; Else Calculate P and Q: xp ¼ p; yp ¼ a*p*p+b*p+c; xq ¼ q; yq ¼ a*q*q+b*q+c; point ¼ 2; xh ¼ xp; yh ¼ yp; xi ¼ xq; yi ¼ yq; Return;

References [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

Newman WM, Sproull RF. Principles of interactive computer graphics. New York: McGraw-Hill; 1979. Sproull RF, Sutherland IE. A clipping divider. In: Proceedings of Fall Joint Computer Conference. Washington: Thompson Books; 1968. p. 765–75. Liang YD, Barsky BA. A new concept and method for line clipping. ACM Transactions on Graphics 1984;3(1):1–22. Nicholl TM, Lee DT, Nicholl RA. An efficient new algorithm for 2-D line clipping: Its development and analysis. Computer Graphics 1987;21(4):253–92. Wang H, Wu R, Cai S. A new efficient line clipping algorithm based on geometric transformation. Journal of Software 1998;9(10):728–33 (in Chinese). Wang J, Liang Y, Peng Q. A 2-D line clipping algorithm with the least arithmetic operations. Chinese Journal of Computers 1991;14(7):495–504 (in Chinese). Sun J, et al. Computer graphics. 3rd ed. Beijng: Tsinghua University Press; 1998 (in Chinese). Tang R, Wang J, Peng Q, et al. Course of computer graphics. Beijing: Science Press; 2000 (in Chinese). Rogers DF. Procedural elements for computer graphics. Beijing: Science Press; 1988 (in Chinese). Yao H, Song P, Zhang G. Clipping algorithm and practice of circular window. Journal of Computer-Aided Design & Computer Graphics 1992;4(3):14–20 (in Chinese). Liu Y. Circular and elliptic clipping windows. Computer Engineering and Design 1994;15(4):33–7 (in Chinese). Shen Q, Zhou L, Zhou R. A new clipping algorithm against circular window. Journal of Computer-Aided Design & Computer Graphics 1997;9(6):538–42 (in Chinese). Cai M, Yuan C, Song J, Cai S. A fast line clipping algorithm against circular windows. Journal of Computer-Aided Design & Computer Graphics 2001;13(12):1063–7 (in Chinese). Lu G, Xing J, Tan J. New clipping algorithm for line against circular window with multi-encoding approach. Journal of Computer-Aided Design & Computer Graphics 2002;12:1133–7 (in Chinese). Lu G, Wu X, Peng Q. An efficient line clipping algorithm based on adaptive line rejection. Computers & Graphics 2002;16(3):409–15.

ARTICLE IN PRESS 560 [16] [17] [18] [19] [20]

Q. Wu et al. / Computers & Graphics 30 (2006) 540–560 Va´clav S. A fast algorithm for line clipping by convex polyhedron in E3. Computers & Graphics 1997;21(2):209–14. Va´clav S. An efficient algorithm for line clipping by convex polygon. Computers & Graphics 1993;17(4):417–21. Day JD. An algorithm for clipping lines in object and image space. Computers & Graphics 1992;16(4):421–6. Andreev R, Sofianska E. New algorithm for two-dimensional line clipping. Computers & Graphics 1991;15(4):519–26. Shi K, Edwards JA, Cooper DC. An efficient line clipping algorithm. Computers & Graphics 1990;14(2):297–301.