curve clipping

Post on 11-May-2015

8.086 Views

Category:

Education

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

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

inside the window, we save the object.

Clipping window

Bounding rectangle

Case 2• If the rectangle is determined to be completely

outside the window, we discard the object

Object

Case 3

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

• 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.

Circle clipping

Xc+RX LEFT

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

xc

Clipping window

Circle clipping cont..

If XC - R > Xright Then the circle is discarded

X right Xc -R XC

R

Circle clipping cont..

Y top

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

Clipping window

Circle clipping cont..

Y bottom

Yc + R

If YC +R <Ybottom Then the circle is discarded

Circle clippingcont..

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

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

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

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

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

Spline curve : definition

Specifying Splines

Example : Third order spline

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

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

Bézier Clipping

00t

( )p t

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

0

Bézier Clipping

00t

( )p t

Polynomial ( ) in Bezier formp t

0

Bézier Clipping

0 00t

( )p t

Convex hull reconstruction

Bézier Clipping

0 00t

( )p t

Intersect convex hull with -axist

Bézier Clipping

110

t

( )p t

1 1The new interval [ , ]

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

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

2. Quadratic Clipping

Quadratic Clipping

• Idea– Use quadratic bounds

• Motivation– To improve the convergence rate

Quadratic Bounds

Upper bound

Lower bound

Quadratic Bounds

• But, how to compute the quadratic bounds efficiently?

Quadratic Bounds

• Approximated quadratic bounds

Upper bound

Lower bound

Best quadratic approximant

Quadratic Clipping

0 00t

( )p t

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

Quadratic Clipping

00t

( )p t

Polynomial ( ) in Bezier formp t

0

Quadratic Clipping

00t

( )p t

The best quadratic approximant of q p

0q

0

Quadratic Clipping

00t

( )p t

0 0Bounding quadratic functions and M m

0

0q

0m

0M

Quadratic Clipping

00t

( )p t

0 0Intersect and with -axisM m t

0

0q

0m

0M

Quadratic Clipping

0t

2nd iteration

( )p t

1q

11

Quadratic Clipping

0t

2nd iteration

( )p t

1q

11

1M

1m

Quadratic Clipping

0t

3rd iteration

( )p t

22

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

top related