-
Notifications
You must be signed in to change notification settings - Fork 0
/
incomplete.js
66 lines (62 loc) · 2.14 KB
/
incomplete.js
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
import { Circle } from 'circle.js';
export class IncompleteCircle {
constructor(start, end, radius){
this.start = start;
this.end = end;
this.radius = radius;
}
/**
*
* Gets all quadrants present in the incomplete circle
*
*/
allQuadrants () {
const startQuad = Circle.getQuadrant(this.start);
const endQuad = Circle.getQuadrant(this.end);
let quadrants = [startQuad];
if(( Circle.getNatural(this.start) <= Circle.getNatural(this.end) ) && ( startQuad === endQuad )) return quadrants;
let i = ( startQuad + 1 );
while((i % 5) !== endQuad){
if(i % 5 !== 0) quadrants.push(i % 5);
i++;
}
quadrants.push(endQuad);
return quadrants;
}
getDimensions () {
if(this.start === this.end) return null;
const quadrants = this.allQuadrants();
const quantity = quadrants.length;
const start = quadrants[0];
const radius = this.radius;
if(quantity === 1){
}
if(quantity === 2){
}
if(quantity === 3){
}
if(quantity === 4){
const firstAngle = Circle.getRadians(this.start);
const lastAngle = Circle.getRadians(this.end);
if(start === 1){
const wing = Math.max(Math.cos(firstAngle), Math.cos(lastAngle));
return [radius * ( 1 + wing ), 2 * radius];
}
if(start === 2){
const wing = Math.max(Math.sin(firstAngle), Math.sin(lastAngle));
return [2 * radius, radius * ( 1 + wing )];
}
if(start === 3){
const wing = Math.max(Math.abs(Math.cos(firstAngle)), Math.cos(Math.sin(lastAngle)));
return [radius * ( 1 + wing ), 2 * radius];
}
if(start === 4){
const wing = Math.max(Math.abs(Math.sin(firstAngle)), Math.sin(Math.sin(lastAngle)));
return [2 * radius, radius * ( 1 + wing )];
}
}
if(quantity === 5){
return [2 * radius, 2 * radius];
}
}
}