-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpoint.js
More file actions
58 lines (48 loc) · 1.06 KB
/
point.js
File metadata and controls
58 lines (48 loc) · 1.06 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
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.pmove = function(r, deg) {
this.x += r * Math.cos(deg * Math.PI / 180);
this.y += r * Math.sin(deg * Math.PI / 180);
return this;
};
Point.prototype.move = function(dx, dy) {
this.x += dx;
this.y += dy;
return this;
};
Point.prototype.add = function(pt) {
this.x += pt.x;
this.y += pt.y
return this;
};
Point.prototype.scale = function(sx, sy) {
this.x *= sx;
if (typeof(sy) != 'undefined') {
this.y *= sy
}
return this;
};
Point.prototype.set = function(x, y) {
this.x = x;
this.y = y;
return this;
};
Point.prototype.pset = function(r, deg) {
this.x = r * Math.cos(deg * Math.PI / 180);
this.y = r * Math.sin(deg * Math.PI / 180);
return this;
};
Point.prototype.toString = function() {
return this.x + "," + this.y;
};
Point.prototype.m = function() {
return "m" + this.x + "," + this.y;
};
p = function(x, y) {
return new Point(x, y);
};
pp = function(r, deg) {
return new Point(r * Math.cos(deg * Math.PI / 180), r * Math.sin(deg * Math.PI / 180));
};