Data Structures & Alogs HW_Part_22

Data Structures & Alogs HW_Part_22 - 85 18 / \ 17...

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

View Full Document Right Arrow Icon
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 | | | ---------------------
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Data Structures &amp;amp; Alogs HW_Part_22 - 85 18 / \ 17...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online