-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.pde
37 lines (26 loc) · 836 Bytes
/
util.pde
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
/*
© 2020 Alex Harding
Physics Clock by Alex Harding
www.alexharding.io
https://hackaday.io/project/176037-concrete-physics-clock
https://github.com/arcadeperfect/Physics-Clock-Processing
Originally based on Dan Shiffman's "boxes" example for his Box2D wrapper for processing:
https://github.com/shiffman/Box2D-for-Processing/tree/master/Box2D-for-Processing/dist/box2d_processing/examples/Boxes
*/
// Utility functions
void vLine(PVector p1, PVector p2) {
line(p1.x, p1.y, p2.x, p2.y);
}
void vPoint(PVector p) {
point(p.x, p.y);
}
void magLine(PVector pos, PVector dir, float mag) {
// draw line from pos with diretion dir and magnitude mag
pushMatrix();
translate(pos.x, pos.y);
line(0, 0, dir.x*mag, dir.y*mag);
popMatrix();
}
float vDist(PVector p1, PVector p2) {
return dist(p1.x, p1.y, p2.x, p2.y);
}