File tree Expand file tree Collapse file tree 1 file changed +3
-44
lines changed Expand file tree Collapse file tree 1 file changed +3
-44
lines changed Original file line number Diff line number Diff line change @@ -7,56 +7,15 @@ function sign(x) {
7
7
) ;
8
8
}
9
9
10
- function hypot ( x , y ) {
11
- return Math . sqrt ( x * x + y * y ) ;
12
- }
13
-
14
10
// adapted from Mike Bostock's https://observablehq.com/@mbostock/smith-chart
15
- function resistanceCircle ( R ) {
16
- return [
17
- R / ( R + 1 ) , // cx
18
- 0 , // cy
19
- 1 / ( R + 1 ) // cr
20
- ] ;
21
- }
22
-
23
- function reactanceCircle ( X ) {
24
- return [
25
- 1 , // cx
26
- 1 / X , // cy
27
- 1 / Math . abs ( X ) // cr
28
- ] ;
29
- }
30
-
31
- function circleCircleIntersect ( A , B ) {
32
- var ax = A [ 0 ] ;
33
- var ay = A [ 1 ] ;
34
- var ar = A [ 2 ] ;
35
-
36
- var bx = B [ 0 ] ;
37
- var by = B [ 1 ] ;
38
- var br = B [ 2 ] ;
39
-
40
- var dx = bx - ax ;
41
- var dy = by - ay ;
42
- var d = hypot ( dx , dy ) ;
43
-
44
- var x = ( dx * dx + dy * dy - br * br + ar * ar ) / ( 2 * d ) ;
45
- var y = sign ( ay ) * Math . sqrt ( ar * ar - x * x ) ;
46
- return [
47
- ax + ( dx * x + dy * y ) / d ,
48
- ay + ( dy * x - dx * y ) / d
49
- ] ;
50
- }
51
-
52
11
function smith ( a ) {
53
12
var R = a [ 0 ] ;
54
13
var X = a [ 1 ] ;
55
14
56
- if ( isNaN ( X ) || isNaN ( R ) ) return ;
57
15
if ( R === Infinity || Math . abs ( X ) === Infinity ) return [ 1 , 0 ] ;
58
- if ( X === 0 ) return [ ( R - 1 ) / ( R + 1 ) , 0 ] ;
59
- return circleCircleIntersect ( reactanceCircle ( X ) , resistanceCircle ( R ) ) ;
16
+
17
+ var D = ( R + 1 ) * ( R + 1 ) + X * X ;
18
+ return [ ( R * R + X * X - 1 ) / D , 2 * X / D ] ;
60
19
}
61
20
62
21
function transform ( subplot , a ) {
You can’t perform that action at this time.
0 commit comments