20/12/15 13:07:06.08 QEfzM0Mb.net
source('toolmini.R')
L=5
bc2a <- function(b,c, L=5){
sub <- function(a){
th=3*pi/5
A=0i
B=c+0i
C=b*(cos(pi-th)+1i*sin(pi-th))+B
E=a*(cos(th)+1i*sin(th))+A
yde=tan(th-(pi-th))*(0-Re(E))+Im(E)
de=1i*yde
ybc=tan(2*pi-2*th)*(0-Re(C))+Im(C)
bc=1i*ybc
D=intsect(E,de,C,bc)
abs(A-B)+abs(B-C)+abs(C-D)+abs(D-E)+abs(E-A) - L
}
sub=Vectorize(sub)
uniroot(sub,c(1e-12,L-b-c))$root}
bc2S <- function(b,c){
a=bc2a(b,c)
th=3*pi/5
A=0i
B=c+0i
C=b*(cos(pi-th)+1i*sin(pi-th))+B
E=a*(cos(th)+1i*sin(th))+A
yde=tan(th-(pi-th))*(0-Re(E))+Im(E)
de=1i*yde
ybc=tan(2*pi-2*th)*(0-Re(C))+Im(C)
bc=1i*ybc
D=intsect(E,de,C,bc)
ABC2S(A,E,D)+ABC2S(A,D,C)+ABC2S(A,C,B)
}