-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphylib.h
More file actions
110 lines (77 loc) · 2.51 KB
/
phylib.h
File metadata and controls
110 lines (77 loc) · 2.51 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#define PHYLIB_BALL_RADIUS (28.5) // mm
#define PHYLIB_BALL_DIAMETER (2*PHYLIB_BALL_RADIUS)
#define PHYLIB_HOLE_RADIUS (2*PHYLIB_BALL_DIAMETER)
#define PHYLIB_TABLE_LENGTH (2700.0) // mm
#define PHYLIB_TABLE_WIDTH (PHYLIB_TABLE_LENGTH/2.0) // mm
#define PHYLIB_SIM_RATE (0.0001) // s
#define PHYLIB_VEL_EPSILON (0.01) // mm/s
#define PHYLIB_DRAG (150.0) // mm/s^2
#define PHYLIB_MAX_TIME (600) // s
#define PHYLIB_MAX_OBJECTS (26)
typedef enum {
PHYLIB_STILL_BALL = 0,
PHYLIB_ROLLING_BALL = 1,
PHYLIB_HOLE = 2,
PHYLIB_HCUSHION = 3,
PHYLIB_VCUSHION = 4,
} phylib_obj;
typedef struct {
double x;
double y;
} phylib_coord;
typedef struct {
unsigned char number;
phylib_coord pos;
} phylib_still_ball;
typedef struct {
unsigned char number;
phylib_coord pos;
phylib_coord vel;
phylib_coord acc;
} phylib_rolling_ball;
typedef struct {
phylib_coord pos;
} phylib_hole;
typedef struct {
double y;
} phylib_hcushion;
typedef struct {
double x;
} phylib_vcushion;
typedef union {
phylib_still_ball still_ball;
phylib_rolling_ball rolling_ball;
phylib_hole hole;
phylib_hcushion hcushion;
phylib_vcushion vcushion;
} phylib_untyped;
typedef struct {
phylib_obj type;
phylib_untyped obj;
} phylib_object;
typedef struct {
double time;
phylib_object *object[PHYLIB_MAX_OBJECTS];
} phylib_table;
phylib_table *phylib_segment(phylib_table *table);
phylib_object* phylib_new_still_ball(unsigned char number, phylib_coord* pos);
phylib_table* phylib_new_table(void);
void phylib_add_object(phylib_table* table, phylib_object* object);
void phylib_free_table(phylib_table* table);
phylib_object* phylib_new_rolling_ball(unsigned char number, phylib_coord* pos, phylib_coord* vel, phylib_coord* acc);
phylib_object* phylib_new_hole(phylib_coord* pos);
phylib_object* phylib_new_hcushion(double y);
phylib_object* phylib_new_hcushion(double y);
phylib_table* phylib_new_table(void);
void phylib_copy_object(phylib_object** dest, phylib_object** src);
phylib_table* phylib_copy_table(phylib_table* table);
phylib_coord phylib_sub(phylib_coord c1, phylib_coord c2);
double phylib_length(phylib_coord c);
double phylib_dot_product(phylib_coord a, phylib_coord b);
double phylib_distance(phylib_object* obj1, phylib_object* obj2);
void phylib_roll(phylib_object *new, phylib_object *old, double time);
unsigned char phylib_stopped(phylib_object *object);
void phylib_bounce(phylib_object **a, phylib_object **b);
unsigned char phylib_rolling( phylib_table *t );
char *phylib_object_string(phylib_object *object);
phylib_object* phylib_new_vcushion(double x);