20/10/01 11:08:44.59 MUVtJ7n/.net
>>231
暇つぶしにプログラム組んで計算させてみた。
# y=tan(A)(x-a1)+a2 ,y=tan(B)(x-b1)+b2
koten <- function(a1,a2,a,b1,b2,b){
A=a*pi/180
B=b*pi/180
x = (a1* tan(A) - a2 - b1 *tan(B) + b2)/(tan(A) - tan(B))
y = (a1* tan(A)* tan(B) - b1 *tan(A)* tan(B) + b2 *tan(A) - a2* tan(B))/(tan(A) - tan(B))
c(x,y)
}
# coordinates -> angle BAC
BAC <- function(B,A,C){
if(is.complex(B)|is.complex(A)|is.complex(C)){
a=c(Re(A),Im(A)); b=c(Re(B),Im(B)); c=c(Re(C),Im(C))
}else{a=A;b=B;c=C}
ab=b-a
ac=c-a
dot=sum(ab*ac)
bac=acos(dot/sqrt(sum(ab^2))/sqrt(sum(ac^2)))
return(c(rad=bac,deg=bac*180/pi))
}
c=koten(0,0,9, 1,0,180-75)
d=koten(0,0,3, 1,0,180-51)
B=1+0i
C=c[1]+1i*c[2]
D=d[1]+1i*d[2]
BAC(D,C,B)
実行結果
> BAC(D,C,B)
rad deg
0.2617994 15.0000000