Data Structures &amp; Alogs HW_Part_22

Data Structures &amp; Alogs HW_Part_22 - 85 18 17 89 25...

This preview shows pages 1–4. Sign up to view the full content.

85 13.6 18 /\ 17 89 25 90 \\ 72 99 42 75 13.7 A(20, 90) \ \ B(95, 85) / / C(98, 35) \ \ D(117, 52) / / E(110, 25) 13.8 0 127 --------------------- 0| | C | | | ||| | A |----+----| || D | | | |---------+---------| |B |E | | | |----+----| F | | | ---------------------

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
86 Chap. 13 Advanced Tree Structures 13.9 // Return TRUE iff rectangle R intersects circle with // centerpoint C and radius Rad. boolean CheckIntersect(Rectangle* R, Point* C, double Rad) { double Rad2; Rad2 = Rad * Rad; // Translate coordinates, placing C at the origin R->max.x -= C->x; R->max.y -= C->y; R->min.x -= C->x; R->min.y -= C->y; if (R->max.x < 0) // R to left of circle center if (R->max.y < 0) // R in lower left corner return (R->max.x * R->max.x + R->max.y * R->max.y) < Rad2; else if (R->min.y > 0) // R in upper left corner return (R->max.x * R->max.x + R->min.y * R->min.y) < Rad2; else // R due West of circle return ABS(R->max.x) < Rad; else if (R->min.x > 0) // R to right of circle center if (R->max.y < 0) // R in lower right corner return (R->min.x * R->min.x) < Rad2; else if (R->min.y > 0) // R in upper right corner return (R->min.x * R->min.x + R->min.y + R->min.y) < Rad2; else // R due East of circle return R->min.x < Rad; else // R on circle vertical centerline if (R->max.y < 0) // R due South of circle

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 10/31/2011 for the course BCN 3431 at University of Florida.

Page1 / 4

Data Structures &amp; Alogs HW_Part_22 - 85 18 17 89 25...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online