Go to the source code of this file.
Data Structures | |
| struct | odd |
| struct | point |
| struct | rect |
Defines | |
| #define | max(a, b) ((a) > (b) ? (a) : (b)) |
| #define | min(a, b) ((a) < (b) ? (a) : (b)) |
Typedefs | |
| typedef point | point |
| typedef rect | rect |
Functions | |
| point | addpoint (point p1, point p2) |
| rect | canonrect (rect r) |
| main () | |
| point | makepoint (int x, int y) |
| rect | makerect (point p1, point p2) |
| odd (struct odd y) | |
| int | ptinrect (point p, rect r) |
Variables | |
| odd | y |
|
|
|
|
|
|
|
|
|
||||||||||||
|
Definition at line 4 of file struct.c. References p2, point::x, and point::y. Referenced by main().
|
|
|
Definition at line 13 of file struct.c. References max, min, rect::pt1, rect::pt2, r, point::x, and point::y. Referenced by makerect(). 00013 { /* canonicalize rectangle coordinates */
00014 rect temp;
00015
00016 temp.pt1.x = min(r.pt1.x, r.pt2.x);
00017 temp.pt1.y = min(r.pt1.y, r.pt2.y);
00018 temp.pt2.x = max(r.pt1.x, r.pt2.x);
00019 temp.pt2.y = max(r.pt1.y, r.pt2.y);
00020 return temp;
00021 }
|
|
|
Definition at line 51 of file struct.c. References addpoint(), exit(), i, makepoint(), makerect(), odd(), printf(), rect::pt1, rect::pt2, ptinrect(), point::x, x, point::y, and y. 00051 {
00052 int i;
00053 point x, origin = { 0, 0 }, maxpt = { 320, 320 };
00054 point pts[] = { -1, -1, 1, 1, 20, 300, 500, 400 };
00055 rect screen = makerect(addpoint(maxpt, makepoint(-10, -10)),
00056 addpoint(origin, makepoint(10, 10)));
00057
00058 for (i = 0; i < sizeof pts/sizeof pts[0]; i++) {
00059 printf("(%d,%d) is ", pts[i].x,
00060 (x = makepoint(pts[i].x, pts[i].y)).y);
00061 if (ptinrect(x, screen) == 0)
00062 printf("not ");
00063 printf("within [%d,%d; %d,%d]\n", screen.pt1.x, screen.pt1.y,
00064 screen.pt2.x, screen.pt2.y);
00065 }
00066 odd(y);
00067 exit(0);
00068 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 23 of file struct.c. References p, point::x, and point::y. Referenced by main(). 00023 { /* make a point from x and y components */
00024 point p;
00025
00026 p.x = x;
00027 p.y = y;
00028 return p;
00029 }
|
|
||||||||||||
|
Definition at line 31 of file struct.c. References canonrect(), p2, rect::pt1, rect::pt2, and r. Referenced by main(). 00031 { /* make a rectangle from two points */
00032 rect r;
00033
00034 r.pt1 = p1;
00035 r.pt2 = p2;
00036 return canonrect(r);
00037 }
|
Here is the call graph for this function:

|
|
Definition at line 46 of file struct.c. References odd::a, printf(), and x. Referenced by main().
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 39 of file struct.c. References p, rect::pt1, rect::pt2, r, point::x, and point::y. Referenced by main(). 00039 { /* is p in r? */
00040 return p.x >= r.pt1.x && p.x < r.pt2.x
00041 && p.y >= r.pt1.y && p.y < r.pt2.y;
00042 }
|
|
|
|
1.3.9.1