分类:
2006-06-01 12:44:00
代码: |
int x1,x2; int i; x1 = x2 = 0; /* find x1 */ for (i = 0; i< 1024 ;i ++) { if (a_width_in[i] && b_width_in[i]) { x1 = i; break; } } /* no intersection */ if (x1 == 1024) return NULL; /* find x2 */ for (i = x1; i< 1024; i++) { if (!(a_width_in[i] && b_width_in[i])) { x2 = i; break; } } |
代码: |
inline ERect rect_intersection(ERect r1, ERect r2) { if(r1.IsValid() == false || r2.IsValid() == false) return ERect(); ERect r3; r3.left = max_c(r1.left, r2.left); r3.top = max_c(r1.top, r2.top); r3.right = min_c(r1.right, r2.right); r3.bottom = min_c(r1.bottom, r2.bottom); return r3; } bool ERect::Intersect(float l, float t, float r, float b) const { if(!IsValid() || !(l <= r && t <= b)) return false; if(max_c(left, l) > min_c(right, r)) return false; if(max_c(top, t) > min_c(bottom, b)) return false; return true; } |