File tree Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,32 @@ var arraysToCalcdata = require('../scatter/arrays_to_calcdata');
10
10
var calcSelection = require ( '../scatter/calc_selection' ) ;
11
11
var calcMarkerSize = require ( '../scatter/calc' ) . calcMarkerSize ;
12
12
13
+ function sq ( x ) {
14
+ return x * x ;
15
+ }
16
+
17
+ function gammaTransformReal ( re , im ) {
18
+ var denom = sq ( re + 1.0 ) + sq ( im ) ;
19
+ var result = ( sq ( re ) + sq ( im ) - 1.0 ) / denom ;
20
+ return result ;
21
+ }
22
+
23
+ function gammaTransformImaginary ( re , im ) {
24
+ var denom = sq ( re + 1.0 ) + sq ( im ) ;
25
+ var result = ( 2 * im ) / denom ;
26
+ return result ;
27
+ }
28
+
29
+ function cart2pol ( re , im ) {
30
+ var r = Math . sqrt ( sq ( re ) + sq ( im ) ) ;
31
+ var theta = Math . atan2 ( im , re ) ;
32
+
33
+ return {
34
+ r : r ,
35
+ theta : theta ,
36
+ } ;
37
+ }
38
+
13
39
module . exports = function calc ( gd , trace ) {
14
40
var fullLayout = gd . _fullLayout ;
15
41
var subplotId = trace . subplot ;
@@ -26,8 +52,10 @@ module.exports = function calc(gd, trace) {
26
52
var cdi = cd [ i ] = { } ;
27
53
28
54
if ( isNumeric ( re ) && isNumeric ( im ) ) {
29
- cdi . re = re ;
30
- cdi . im = im ;
55
+ var pol = cart2pol ( gammaTransformReal ( re , im ) , gammaTransformImaginary ( re , im ) ) ;
56
+
57
+ cdi . re = pol . r ;
58
+ cdi . im = pol . theta ;
31
59
} else {
32
60
cdi . re = BADNUM ;
33
61
}
You can’t perform that action at this time.
0 commit comments