X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=akamaru.c;h=22b247736717e1b044216ad0763e136168a31044;hb=4e16902eb4a956c7ea79cb4d7f7e56419ea29012;hp=8a9e587b40e66da2259011549be4fd2e97820e14;hpb=97642dcac23601e6a30336706a2e47c399f3793c;p=akamaru diff --git a/akamaru.c b/akamaru.c index 8a9e587..22b2477 100644 --- a/akamaru.c +++ b/akamaru.c @@ -12,13 +12,10 @@ * corrections at the end instead of meaning as it goes. */ -#include -#include -#include -#include +#include #include #include -#include +#include #include #include "akamaru.h" @@ -27,6 +24,50 @@ const double elasticity = 0.7; const double friction = 1; const double gravity = 20; +void +object_init (Object *object, double x, double y, double mass) +{ + object->position.x = x; + object->position.y = y; + object->previous_position.x = x; + object->previous_position.y = y; + object->mass = mass; +} + +void +spring_init (Spring *spring, Object *a, Object *b, double length) +{ + spring->a = a; + spring->b = b; + spring->length = length; +} + +void +stick_init (Stick *stick, Object *a, Object *b, double length) +{ + stick->a = a; + stick->b = b; + stick->length = length; +} + +void +string_init (String *string, Object *a, Object *b, double length) +{ + string->a = a; + string->b = b; + string->length = length; +} + +void +offset_spring_init (OffsetSpring *spring, Object *a, Object *b, + double dx, double dy) +{ + spring->a = a; + spring->b = b; + spring->dx = dx; + spring->dy = dy; +} + void polygon_init (Polygon *p, int num_points, ...) { @@ -157,7 +198,7 @@ model_accumulate_forces (Model *model) model->objects[i].force.x * model->objects[i].force.x + model->objects[i].force.y * model->objects[i].force.y; - if (f > 1000000) + if (f > 100000000) abort(); } }