Sho Iizuka
June 13, 2014
31

# 円と円の交点の求め方

June 13, 2014

## Transcript

1. ԁͱԁͷަ఺ͷٻΊํ
!TIPSB@LVKJSB

2. w *\$1\$ͷϥΠϒϥϦΛ੔උ͍ͯͨ͠Β
ʮԁͱԁͷަ఺ʯͷίʔυ͕Α͘෼͔Βͳ͔ͬͨͷ
Ͱղઆ͠·͢ɻ
w ࢀߟʹͨ͠ίʔυ͸ίϨͰ͢

3. ໰୊ͷίʔυ
pair cc_cross(const C& c1, const C& c2) {
double d = abs(c1.p - c2.p);
double rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
double rs = sqrt(c1.r*c1.r - rc*rc);
P diff = (c2.p - c1.p) / d;
return make_pair(c1.p + diff * P(rc, rs),
c1.p + diff * P(rc, -rs));
}

4. double d = abs(c1.p - c2.p);
d
c1.p
c2.p

5. double rc =
(d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
cos = a2+b2 c2
2ab
༨ݭఆཧ
b
c
a
θ

6. double rc =
(d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
b
bcosθ
θ
cos =
a2 + b2 c2
2ab
b cos =
a2 + b2 c2
2a

7. double rs = sqrt(c1.r*c1.r - rc*rc);
c1.r
rc
rs

8. P diff = (c2.p - c1.p) / d;

=> diffは c1.p→c2.p の単位ベクトル
d
c1.p
c2.p

9. c1.p + diff * P(rc, rs)
௕͘ͳΔͷͰ࣍ͷϖʔδϔ
rc
rs
c1.p

10. diff * P(rc, rs) ͱ͸ʁ
=> rc*diff + rs*rot90(diff) ͷ͜ͱ
di = (x + jy)
rot90(di ) = rot90(x + jy)
= y + jx
di P(rc, rs) = (x + jy) · (rc
+ jrs
)
= rc(x + jy) + rs( y + jx)
= rc
di + rs
rot90(di )

11. c1.p + diff * P(rc, -rs)
ઌ΄Ͳͱಉ༷
rc
rs
c1.p

12. ײ૝
w ༨ݭఆཧศརͳΜ͚ͩͲɺΑ͘๨ΕΔ
w KΛֻ͚ͯճసͤ͞ΔςΫχοΫʹؾͮ͘ͷʹ࣌
͕͔͔ؒͬͯ͠·ͬͨʢిؾܥͳΒ೔ৗతʹ࢖ͬͯ
͍Δ͸ͣͳͷʹʣ