]> git.cworth.org Git - akamaru/blobdiff - akamaru.h
Split gtk+ demo code out into main.c. Core model code is now in akamaru.c.
[akamaru] / akamaru.h
diff --git a/akamaru.h b/akamaru.h
new file mode 100644 (file)
index 0000000..bfec60f
--- /dev/null
+++ b/akamaru.h
@@ -0,0 +1,98 @@
+#ifndef __AKAMARU_H__
+#define __AKAMARU_H__
+
+typedef struct _xy_pair Point;
+typedef struct _xy_pair Vector;
+struct _xy_pair {
+  double x, y;
+};
+
+typedef struct _Object Object;
+typedef struct _Stick Stick;
+typedef struct _String String;
+typedef struct _Spring Spring;
+typedef struct _OffsetSpring OffsetSpring;
+typedef struct _Polygon Polygon;
+typedef struct _Offset Offset;
+typedef struct _Model Model;
+
+struct _Object {
+  Vector force;
+
+  Point position;
+  Point previous_position;
+  Vector velocity;
+
+  double mass;
+  double theta;
+};
+
+struct _Stick {
+  Object *a, *b;
+  int length;
+};
+
+struct _String {
+  Object *a, *b;
+  int length;
+};
+
+struct _Offset {
+  int num_objects;
+  Object **objects;
+  int dx, dy;
+};
+
+struct _Spring {
+  Object *a, *b;
+  int length;
+};
+
+struct _OffsetSpring {
+  Object *a, *b;
+  int dx, dy;
+};
+
+struct _Polygon {
+  int num_points;
+  Point *points;
+  Vector *normals;
+  int edge;
+};
+
+struct _Model {
+  int num_objects;
+  Object *objects;
+  int num_sticks;
+  Stick *sticks;
+  int num_strings;
+  String *strings;
+  int num_offsets;
+  Offset *offsets;
+  int num_springs;
+  Spring *springs;
+  int num_offset_springs;
+  OffsetSpring *offset_springs;
+  int num_polygons;
+  Polygon *polygons;
+  double k;
+  double friction;
+
+  Object *anchor_object;
+  Vector anchor_position;
+
+  double theta;
+};
+
+void polygon_init (Polygon *p, int num_points, ...);
+void polygon_init_diamond (Polygon *polygon, double x, double y);
+void polygon_init_rectangle (Polygon *polygon, double x0, double y0,
+                            double x1, double y1);
+
+void model_fini (Model *model);
+
+void model_step (Model *model, double delta_t);
+
+Object *model_find_nearest (Model *model, double x, double y);
+
+#endif