## 2020年6月17日水曜日

### 数学 - Python - 立体的な広がりの中の図形 - 空間図形 - 直線・平面・球の方程式 - 中心、半径

1. ${\left(x-3\right)}^{2}+{y}^{2}+{\left(z+2\right)}^{2}=36$

2. ${\left(x+4\right)}^{2}+{\left(y-3\right)}^{2}+{\left(z-5\right)}^{2}=16$

3. $\begin{array}{l}|\left(2,0,0\right)-\left(0,-4,-6\right)|\\ =|\left(2,4,6\right)|\\ =|2\left(1,2,3\right)|\\ =2\sqrt{1+4+9}\\ =2\sqrt{14}\end{array}$
${\left(x-1\right)}^{2}+{\left(y+2\right)}^{2}+{\left(z+3\right)}^{2}=14$

4. $\begin{array}{l}{\left(x-r\right)}^{2}+{\left(y-r\right)}^{2}+{\left(z-r\right)}^{2}={r}^{2}\\ {\left(1-r\right)}^{2}+{\left(4-r\right)}^{2}+{\left(5-r\right)}^{2}={r}^{2}\\ 2{r}^{2}-20r+42=0\\ {r}^{2}-10r+21=0\\ \left(r-3\right)\left(r-7\right)=0\end{array}$

よって求める球の方程式は、

$\begin{array}{l}{\left(x-3\right)}^{2}+{\left(y-3\right)}^{2}+{\left(z-3\right)}^{2}=9\\ {\left(x-7\right)}^{2}+{\left(y-7\right)}^{2}+{\left(z-7\right)}^{2}=49\end{array}$

5. ${\left(x-a\right)}^{2}+{\left(y-b\right)}^{2}+{\left(z-c\right)}^{2}={r}^{2}$
$\left\{\begin{array}{l}{\left(1-a\right)}^{2}+{b}^{2}+{c}^{2}={r}^{2}\\ {a}^{2}+{\left(2-b\right)}^{2}+{c}^{2}={r}^{2}\\ {a}^{2}+{b}^{2}+{\left(3-c\right)}^{2}={r}^{2}\\ {\left(1-a\right)}^{2}+{\left(2-b\right)}^{2}+{\left(3-c\right)}^{2}={r}^{2}\end{array}$
$\begin{array}{l}2\left({a}^{2}+{b}^{2}+{c}^{2}\right)+{r}^{2}=3{r}^{2}\\ {a}^{2}+{b}^{2}+{c}^{2}={r}^{2}\end{array}$
$\begin{array}{l}{\left(1-a\right)}^{2}={a}^{2}\\ 1-2a+{a}^{2}={a}^{2}\\ a=\frac{1}{2}\end{array}$
$\begin{array}{l}{\left(2-b\right)}^{2}={b}^{2}\\ 4-4b=0\\ b=1\end{array}$
$\begin{array}{l}{\left(3-c\right)}^{2}={c}^{2}\\ 9-6c=0\\ c=\frac{3}{2}\end{array}$
${r}^{2}=\frac{1}{4}+1+\frac{9}{4}=\frac{14}{4}=\frac{7}{2}$

よって求める球の方程式は、

${\left(x-\frac{1}{2}\right)}^{2}+{\left(y-1\right)}^{2}+{\left(z-\frac{3}{2}\right)}^{2}=\frac{7}{2}$

コード

#!/usr/bin/env python3
from sympy import solve
from sympy.plotting import plot3d
from sympy.abc import x, y, z

print('40.')

eq1 = (x - 3) ** 2 + (y - 3) ** 2 + (z - 3) ** 2 - 9
eq2 = (x - 7) ** 2 + (y - 7) ** 2 + (z - 7) ** 2 - 49

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

p = plot3d(
*solve(eq1, z),
*solve(eq2, z),
(x, 0, 14),
(y, 0, 14),
show=False
)
for o, color in zip(p, colors):
o.line_color = color
p.save(f'sample40.png')

p.show()


% ./sample40.py
40.
%