/
polar_coordinate.ts
48 lines (38 loc) · 1.04 KB
/
polar_coordinate.ts
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
/*
Project: Arena game
Author: Copyright (C) 2015, Atanas Laskov
License: BSD license, see LICENSE.md for more details.
http://www.atanaslaskov.com/arena/
*/
/// <reference path="vector.ts" />
// Polar coordinate represented as (angle; radius)
//
class PolarCoordinate{
public angle: number;
public radius: number;
constructor(angle:number =0, radius:number =0) {
this.angle = angle;
this.radius = radius;
}
public copy(): PolarCoordinate {
return new PolarCoordinate(this.angle, this.radius);
}
public vector(): Vector {
return new Vector(
Math.cos(this.angle)*this.radius,
Math.sin(this.angle)*this.radius
);
}
}
// Polar coordinate with an area of effect arount it (areal)
//
class PolarCoordinateAreal extends PolarCoordinate{
public areal: number;
constructor(angle:number =0, radius:number =0, areal:number =0) {
super(angle,radius);
this.areal = areal;
}
public copy(): PolarCoordinateAreal {
return new PolarCoordinateAreal(this.angle, this.radius, this.areal);
}
}