tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
19
Task/Problem-of-Apollonius/J/problem-of-apollonius-1.j
Normal file
19
Task/Problem-of-Apollonius/J/problem-of-apollonius-1.j
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
require 'math/misc/amoeba'
|
||||
|
||||
NB.*apollonius v solves Apollonius problems
|
||||
NB. y is Cx0 Cy0 R0, Cx1 Cy1 R1,: Cx2 Cy2 R2
|
||||
NB. x are radius scale factors to control which circles are included
|
||||
NB. in the common tangent circle. 1 to surround, _1 to exclude.
|
||||
NB. returns Cxs Cys Rs
|
||||
apollonius =: verb define"1 _
|
||||
1 apollonius y
|
||||
:
|
||||
centers=. 2{."1 y
|
||||
radii=. x * {:"1 y
|
||||
goal=. 1e_20 NB. goal simplex volume
|
||||
dist=. radii + [: +/"1&.:*: centers -"1 ] NB. distances to tangents
|
||||
'soln err'=. ([: +/@:*:@, -/~@dist) f. amoeba goal centers
|
||||
if. err > 10 * goal do. '' return. end. NB. no solution found
|
||||
avg=. +/ % #
|
||||
(, avg@dist) soln
|
||||
)
|
||||
7
Task/Problem-of-Apollonius/J/problem-of-apollonius-2.j
Normal file
7
Task/Problem-of-Apollonius/J/problem-of-apollonius-2.j
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
]rctst=: 0 0 1,4 0 1,:2 4 2 NB. Task circles
|
||||
0 0 1
|
||||
4 0 1
|
||||
2 4 2
|
||||
(_1 _1 _1 ,: 1 1 1) apollonius rctst NB. internally & externally tangent solutions
|
||||
2 0.83333333 1.1666667
|
||||
2 2.1 3.9
|
||||
Loading…
Add table
Add a link
Reference in a new issue