-
Notifications
You must be signed in to change notification settings - Fork 0
/
rotationElliptic.js
executable file
·44 lines (38 loc) · 1.37 KB
/
rotationElliptic.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
"use strict";
var rotationElliptic={};
rotationElliptic.scale=20;
rotationElliptic.baseLength=0.5;
rotationElliptic.setup=function(center,left,right){
// rotational symmetry at center
rotationElliptic.nCenter=center;
rotationElliptic.gamma=Math.PI/rotationElliptic.nCenter;
rotationElliptic.nExtra=left;
var alpha=Math.PI/rotationElliptic.nExtra;
rotationElliptic.centerX=-rotationElliptic.baseLength*Math.cos(rotationElliptic.gamma);
rotationElliptic.centerY=-rotationElliptic.baseLength*Math.sin(rotationElliptic.gamma);
rotationElliptic.radius=rotationElliptic.baseLength*Math.sin(rotationElliptic.gamma)/Math.sin(alpha/2);
}
// poincare disc??
rotationElliptic.map=function(inputImagePosition,colorPosition,spacePosition,canvasPosition){
var isFinished=false;
var iter=0;
var iterMax=iterMaximum;
inputImagePosition.set(spacePosition);
colorPosition.x=0; // as parity for 2 colors
while (!isFinished){
inputImagePosition.rotationSymmetry(rotationElliptic.nCenter);
iter++;
if (iter>iterMax){
return false;
}
else if (!inputImagePosition.circleInversionOutsideIn(rotationElliptic.centerX,rotationElliptic.centerY,rotationElliptic.radius)){
isFinished=true;
}
else {
colorPosition.x++;
}
}
basicRosette(inputImagePosition,rotationElliptic.nCenter);
inputImagePosition.scale(rotationElliptic.scale);
return true;
}