]> git.cworth.org Git - akamaru/blob - akamaru.h
Indent to 8 columns rather than 2
[akamaru] / akamaru.h
1 #ifndef __AKAMARU_H__
2 #define __AKAMARU_H__
3
4 typedef struct _xy_pair Point;
5 typedef struct _xy_pair Vector;
6 struct _xy_pair {
7   double x, y;
8 };
9
10 typedef struct _Object Object;
11 typedef struct _Stick Stick;
12 typedef struct _String String;
13 typedef struct _Spring Spring;
14 typedef struct _OffsetSpring OffsetSpring;
15 typedef struct _Spacer Spacer;
16 typedef struct _Anchor Anchor;
17 typedef struct _Polygon Polygon;
18 typedef struct _Offset Offset;
19 typedef struct _Model Model;
20
21 struct _Object {
22   Vector force;
23
24   Point position;
25   Point previous_position;
26   Vector velocity;
27
28   double mass;
29   double theta;
30 };
31
32 struct _Stick {
33   Object *a, *b;
34   int length;
35 };
36
37 struct _String {
38   Object *a, *b;
39   int length;
40 };
41
42 struct _Offset {
43   int num_objects;
44   Object **objects;
45   int dx, dy;
46 };
47
48 struct _Spring {
49   Object *a, *b;
50   int length;
51 };
52
53 struct _OffsetSpring {
54   Object *a, *b;
55   int dx, dy;
56 };
57
58 struct _Spacer {
59   Object *a, *b;
60   int length;
61 };
62
63 struct _Anchor {
64   Object *object;
65   double x, y;
66 };
67
68 struct _Polygon {
69   int num_points;
70   Point *points;
71   Vector *normals;
72   int enclosing;
73 };
74
75 struct _Model {
76   int num_objects;
77   Object *objects;
78   int num_sticks;
79   Stick *sticks;
80   int num_strings;
81   String *strings;
82   int num_offsets;
83   Offset *offsets;
84   int num_springs;
85   Spring *springs;
86   int num_offset_springs;
87   OffsetSpring *offset_springs;
88   int num_spacers;
89   Spacer *spacers;
90   int num_anchors;
91   Anchor *anchors;
92   int num_polygons;
93   Polygon *polygons;
94   double k;
95   double friction;
96
97   Anchor mouse_anchor;
98
99   double theta;
100 };
101
102 void object_init (Object *object, double x, double y, double mass);
103 void offset_spring_init (OffsetSpring *spring,
104                          Object *a, Object *b, double dx, double dy);
105 void spring_init (Spring *spring, Object *a, Object *b, double length);
106 void stick_init (Stick *stick, Object *a, Object *b, double length);
107 void string_init (String *string, Object *a, Object *b, double length);
108 void spacer_init (Spacer *spacer, Object *a, Object *b, double length);
109 void anchor_init (Anchor *anchor, Object *object, double x, double y);
110
111 void polygon_init (Polygon *p, int enclosing, int num_points, ...);
112 void polygon_init_diamond (Polygon *polygon, double x, double y);
113 void polygon_init_rectangle (Polygon *polygon, double x0, double y0,
114                              double x1, double y1);
115 void polygon_init_enclosing_rectangle (Polygon *polygon, double x0, double y0,
116                                        double x1, double y1);
117
118 void model_fini (Model *model);
119
120 void model_step (Model *model, double delta_t);
121
122 Object *model_find_nearest (Model *model, double x, double y);
123
124 #endif