39
Curve clipping

Curve clipping

Embed Size (px)

Citation preview

Page 1: Curve clipping

Curve clipping

Page 2: Curve clipping

• The bounding rectangle for a curved object can be used first to test for overlap with a rectangular clip window (we can use polygon clipping) XMAX , Y MAXXMIN , Y MAX

XMAX , Y MIN

XMIN , Y MIN

Object

Page 3: Curve clipping

Case 1• If the bounding rectangle for the object is completely

inside the window, we save the object.

Clipping window

Bounding rectangle

Page 4: Curve clipping

Case 2• If the rectangle is determined to be completely

outside the window, we discard the object

Object

Page 5: Curve clipping

Case 3

• If the two regions overlap, we will need to solve the simultaneous line-curve equations to obtain the clipping intersection points.

Page 6: Curve clipping

• finding intersection points by solving the curve and boundary equations simultaneously sometimes takes a long time.

•We have to consider special curves as circles and ellipses before solving the equations simultaneously.

Page 7: Curve clipping

Circle clipping

Xc+RX LEFT

-If XC + R < XLEFT Then the circle is discarded .-No need for bounding triangle

xc

Clipping window

Page 8: Curve clipping

Circle clipping cont..

If XC - R > Xright Then the circle is discarded

X right Xc -R XC

R

Page 9: Curve clipping

Circle clipping cont..

Y top

Yc -R If YC - R >Ytop Then the circle is discarded

Clipping window

Page 10: Curve clipping

Circle clipping cont..

Y bottom

Yc + R

If YC +R <Ybottom Then the circle is discarded

Page 11: Curve clipping

Circle clippingcont..

If all the four previous conditions are false then the circle is saved

Page 12: Curve clipping

Circle clipping cont..

Intersection conditions: With right edge:Xc+R>Xright

With left edge:Xc-R<Xleft

With top edge :Yc+R>Ytop

With bottom edge:Yc-R<Ybottom

Page 13: Curve clipping

Circle clipping cont..

Getting intersection points :Example : The intersection with the right edge

α Start (angle=0)

First intersection angle=α

Second intersection

α

X rightXc

1- Simply Cos α = Xright-Xc /R2- Get α

3- y=R sin α

4- the segment from angle 0 to angle α is discarded

5- the segment from angle α to angle 360-α is considered

6- the segment from angle 360-α to angle 360 is considered

Page 14: Curve clipping

Other techniques

• Clip individual point : for point plotted curves , may consume time if

number of points is great.• Curves approximated to poly lines: clip individual line segments , if segment is not small

enough no accurate result , if it is small more than enough , it will be time consuming for linear segments

Page 15: Curve clipping

A Spline Curve : Any Composite curve formed with polynomial sections satisfying specified continuity conditions at the boundary of the pieces.

Spline curve : definition

Page 16: Curve clipping

Specifying Splines

Page 17: Curve clipping

Example : Third order spline

• In order to assure C1 continuity at two extremities, our functions must be of at least degree 3

Page 18: Curve clipping

Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005

18

Convex Hull Property

• Bezier curves lie in the convex hull of their control points

• Hence, even though we do not interpolate all the data, we cannot be too far away

p0

p1 p2

p3

convex hull

Bezier curve

Page 19: Curve clipping

Bézier Clipping

00t

( )p t

0 0Find the root of polynomial ( ) within [ , ]p t

0

Page 20: Curve clipping

Bézier Clipping

00t

( )p t

Polynomial ( ) in Bezier formp t

0

Page 21: Curve clipping

Bézier Clipping

0 00t

( )p t

Convex hull reconstruction

Page 22: Curve clipping

Bézier Clipping

0 00t

( )p t

Intersect convex hull with -axist

Page 23: Curve clipping

Bézier Clipping

110

t

( )p t

1 1The new interval [ , ]

Page 24: Curve clipping

The Approximated Roots

• A sequence of intervals that bound the root of p

• If the width of interval is smaller than the given tolerance, return the root (interval).

0 0 1 1[ , ] [ , ] [ , ]n n

Page 25: Curve clipping

Convergence Rates

• A sequence of intervals that converge to the root:

• How fast does the sequence converge?

0 0 1 1[ , ] [ , ] [ , ]n n

( )i i ih

1 ~ ?i ih h

1i ih C h

Page 26: Curve clipping

2. Quadratic Clipping

Page 27: Curve clipping

Quadratic Clipping

• Idea– Use quadratic bounds

• Motivation– To improve the convergence rate

Page 28: Curve clipping

Quadratic Bounds

Upper bound

Lower bound

Page 29: Curve clipping

Quadratic Bounds

• But, how to compute the quadratic bounds efficiently?

Page 30: Curve clipping

Quadratic Bounds

• Approximated quadratic bounds

Upper bound

Lower bound

Best quadratic approximant

Page 31: Curve clipping

Quadratic Clipping

0 00t

( )p t

0 0Find the root of polynomial ( ) within [ , ]p t

Page 32: Curve clipping

Quadratic Clipping

00t

( )p t

Polynomial ( ) in Bezier formp t

0

Page 33: Curve clipping

Quadratic Clipping

00t

( )p t

The best quadratic approximant of q p

0q

0

Page 34: Curve clipping

Quadratic Clipping

00t

( )p t

0 0Bounding quadratic functions and M m

0

0q

0m

0M

Page 35: Curve clipping

Quadratic Clipping

00t

( )p t

0 0Intersect and with -axisM m t

0

0q

0m

0M

Page 36: Curve clipping

Quadratic Clipping

0t

2nd iteration

( )p t

1q

11

Page 37: Curve clipping

Quadratic Clipping

0t

2nd iteration

( )p t

1q

11

1M

1m

Page 38: Curve clipping

Quadratic Clipping

0t

3rd iteration

( )p t

22

Page 39: Curve clipping

The Approximated Root

• A sequence of intervals that bound the root of p

• If the width of interval is smaller than the given tolerance, return the root (interval).

0 0 1 1[ , ] [ , ] [ , ]n n