Curve clipping


Published on

Published in: Education
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Curve clipping

  1. 1. Curve clipping<br />
  2. 2. 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)<br />XMAX , Y MAX<br />XMIN , Y MAX<br />XMIN , Y MIN<br />XMAX , Y MIN<br />Object<br />
  3. 3. Case 1<br />If the bounding rectangle for the object is completely inside the window, we save the object.<br />Clipping window<br />Bounding rectangle<br />
  4. 4. Case 2<br />If the rectangle is determined to be completely outside the window, we discard the object<br />Object<br />
  5. 5. Case 3<br />If the two regions overlap, we will need to solve the simultaneous line-curve equations to obtain the clipping intersection points.<br />
  6. 6. <ul><li>finding intersection points by solving the curve and boundary equations simultaneously sometimes takes a long time.
  7. 7. We have to consider special curves as circles and ellipses before solving the equations simultaneously.</li></li></ul><li>Circle clipping<br />-If XC + R < XLEFT Then the circle is discarded .<br />-No need for bounding triangle<br />Clipping window<br />X LEFT<br />xc<br />Xc+R<br />
  8. 8. Circle clipping cont..<br />If XC - R > Xright Then the circle is discarded<br />R<br /> X right<br />Xc -R<br />XC<br />
  9. 9. Circle clipping cont..<br />If YC - R >Ytop Then the circle is discarded<br />Yc -R<br />Y top<br />Clipping window<br />
  10. 10. Circle clipping cont..<br />If YC +R <Ybottom Then the circle is discarded<br />Y bottom<br />Yc + R<br />
  11. 11. Circle clippingcont..<br />If all the four previous conditions are false then the circle is saved<br />
  12. 12. Circle clipping cont..<br />Intersection conditions: <br />With right edge:<br />Xc+R>Xright<br />With left edge:<br />Xc-R<Xleft<br />With top edge :<br />Yc+R>Ytop<br />With bottom edge:<br />Yc-R<Ybottom<br />
  13. 13. Circle clipping cont..<br />Getting intersection points :<br />Example : The intersection with the right edge <br />1- Simply<br /> Cos α = Xright-Xc /R<br />2- Get α<br />3- y=R sin α<br />4- the segment from angle 0 to angle α is discarded <br />5- the segment from angle α to angle 360-α is considered<br />6- the segment from angle 360-α to angle 360 is considered<br />First intersection angle=α<br />α<br />Start (angle=0)<br />α<br />Second intersection<br />X right<br />Xc<br />
  14. 14. Other techniques <br />Clip individual point :<br />for point plotted curves , may consume time if number of points is great.<br />Curves approximated to poly lines:<br />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<br />
  15. 15. Spline curve : definition<br />A Spline Curve : Any Composite curve formed with polynomial sections satisfying specified continuity conditions at the boundary of the pieces.<br />
  16. 16. Specifying Splines<br />
  17. 17. Example : Third order spline<br />In order to assure C1 continuity  at two extremities, our functions must be of at least degree 3<br />
  18. 18. 18<br />Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005<br />Convex Hull Property<br />Bezier curves lie in the convex hull of their control points<br />Hence, even though we do not interpolate all the data, we cannot be too far away<br />p1<br />p2<br />convex hull<br />Bezier curve<br />p3<br />p0<br />
  19. 19. Bézier Clipping<br />Problem<br />Given polynomial p withdegree n<br />Find all roots within an interval<br />Algorithm<br />Bézier representation<br />Intersect the convex hull with t-axis<br />Obtain a new interval <br />
  20. 20. Bézier Clipping<br />
  21. 21. Bézier Clipping<br />
  22. 22. Bézier Clipping<br />
  23. 23. Bézier Clipping<br />
  24. 24. Bézier Clipping<br />
  25. 25. The Approximated Roots<br />A sequence of intervals that bound the root of p<br />If the width of interval is smaller than the given tolerance, return the root (interval).<br />
  26. 26. Convergence Rates<br />A sequence of intervals that converge to the root:<br />How fast does the sequence converge?<br />
  27. 27. 2. Quadratic Clipping<br />
  28. 28. Quadratic Clipping<br />Idea<br />Use quadratic bounds<br />Motivation<br />To improve the convergence rate<br />
  29. 29. Quadratic Bounds<br />Upper bound<br />Lower bound<br />
  30. 30. Quadratic Bounds<br />But, how to compute the quadratic bounds efficiently?<br />
  31. 31. Quadratic Bounds<br />Approximated quadratic bounds<br />Upper bound<br />Best quadratic approximant<br />Lower bound<br />
  32. 32. Quadratic Clipping<br />The same type of algorithm as Bézier clipping<br />Convex hull  Quadratic bounds<br />Find the best quadratic approximant q of p in L2 norm<br />Compute error bound of p and q<br />Construct quadratic functions: upper bound M, lower bound m<br />Compute roots of M and m<br />
  33. 33. Quadratic Clipping<br />
  34. 34. Quadratic Clipping<br />
  35. 35. Quadratic Clipping<br />
  36. 36. Quadratic Clipping<br />
  37. 37. Quadratic Clipping<br />
  38. 38. Quadratic Clipping<br />
  39. 39. Quadratic Clipping<br />
  40. 40. Quadratic Clipping<br />
  41. 41. The Approximated Root<br />A sequence of intervals that bound the root of p<br />If the width of interval is smaller than the given tolerance, return the root (interval).<br />