blob: 0fa93a7bd1d6087304ae3117361b70fc228922f0 (
plain) (
blame)
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
|
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <cursor.h>
enum {
RADIUS = 20,
};
typedef struct {
int x, y;
} Vec;
typedef struct {
Point p1, p2;
} Line;
typedef struct {
Point p; /* position */
Vec v; /* velocity */
int m; /* mass */
} Ball;
Vec vsub(Vec v1, Vec v2);
Vec vmuls(Vec v, int a);
Vec vdivs(Vec v, int a);
int vdot(Vec v1, Vec v2);
int vlen(Vec v);
Vec unitnorm(Vec v);
Point ptaddv(Point p, Vec v);
Vec V(int x, int y);
Vec Vpt(Point p, Point q);
int iscollision(Point p, Point q);
|