File: rect.h

package info (click to toggle)
gsumi 0.8-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 344 kB
  • ctags: 421
  • sloc: ansic: 5,088; makefile: 58; sh: 17
file content (39 lines) | stat: -rw-r--r-- 941 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* Simple primitives for manipulating rectangles.*/

#ifndef RECT_H
#define RECT_H

#ifndef BOOL_DEFINED
#define BOOL_DEFINED
typedef int bool;
#define true 1
#define false 0
#endif

#ifndef POINT_DEFINED
#define POINT_DEFINED
typedef struct point {
  double x;
  double y;
} point;
#endif

typedef struct rect {
  double x0, y0;
  double x1, y1;
} rect;

/* Since rectangles are of fixed size, it is expected that they are
   statically allocated (i.e. on the stack). Functions on rectangles,
   however, will be defined in terms of pointers to rectangles.

   Functions with a rectangle return will have a "destination"
   rectangle pointer as the first argument. */

void rect_copy (rect *dest, const rect *src);
void rect_union (rect *dest, const rect *src1, const rect *src2);
void rect_intersect (rect *dest, const rect *src1, const rect *src2);
bool rect_empty (const rect *src);
bool point_inside (rect *rect, point *point);

#endif