<jupyter_start><jupyter_text>3차원 공간의 직선과 평면Lines and Planes of 3D Spaces  3차원 공간의 직선Lines of 3D Spaces 3차원 공간의 직선을 벡터로 표시해 보자.Let's describe a line on a 3D space using vectors. $$    \mathbf{x}=\mathbf{x_0}+t \cdot \mathbf{d}$$ 여기서 $\mathbf{x_0}$는 직선 위의 점, $\mathbf{d}$는 직선의 방향, $t$는 $-\infty$ 와 $\infty$ 사이에서 변화하는 매개변수이다. Here, $\mathbf{x_0}$ is a point on the line, $\mathbf{d}$ is the direction of the line, and $t$ is a parameter that changes between $-\infty$ and $\infty$.   예를 들어 $\mathbf{x}_0=(-1, 1, 1)^T$ 을 지나고 방향은 $\mathbf{d}=(1, 1, 1)^T$ 인 직선을 그려보자.For example, let's plot a line passing $\mathbf{x}_0=(-1, 1, 1)^T$ with direction of $\mathbf{d}=(1, 1, 1)^T$.<jupyter_code>x_0 = np.array([[-1, 1, 1]]).T
d = np.array([[1, 1, 1]]).T
t = np.array([np.arange(-10, 10)])
x = (x_0 + d @ t).tolist()

fig = py.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection='3d')

ax.plot(x[0], x[1], x[2], label='line')
ax.plot((0, x_0[0, 0]), (0, x_0[1, 0]), (0, x_0[2, 0]), label='$\\mathbf{x_0}$')
ax.plot((x_0[0, 0], x_0[0, 0]+d[0, 0]), 
        (x_0[1, 0], x_0[1, 0]+d[1, 0]), 
        (x_0[2, 0], x_0[2, 0]+d[2, 0]), 
        label='$\\mathbf{d}$', linewidth=3)

py.legend(loc=0)<jupyter_output><empty_output><jupyter_text>3차원 공간의 평면Planes of 3D Spaces (Weisstein, <NAME>. "Plane." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Plane.html) 3차원 공간의 평면은 다음 조건을 만족하는 점 $\mathbf{x}$의 집합이다.A 3D plane is a set of points $\mathbf{x}$ satisfying the following condition. $$    \mathbf{n} \cdot \left(\mathbf{x} - \mathbf{x}_0 \right) = 0$$ 여기서 $\mathbf{x}_0$은 평면 위의 한 점이고 $\mathbf{n}$은 평면에 수직인 벡터이다.Here, $\mathbf{x}_0$ is a point on the plane and $\mathbf{n}$ is a vector normal to the plane.  위 내적 값을 시각화 해보자.Let's visualize the inner product values.<jupyter_code># Normal Direction
n = py.matrix([[2, 1, 0.5]]).T
# A point on the plane
x_0 = py.matrix([[1, -2, 0.5]]).T

# Set x y z ranges
x_array = py.linspace(-5, 5, 10+1)
y_array = py.linspace(-5, 5, 10+1)
z_array = py.linspace(-5, 5, 10+1)

# Combinations of x y z coordinates
x_mesh, y_mesh, z_mesh = py.meshgrid(x_array, y_array, z_array)

x_flat = x_mesh.flatten()
y_flat = y_mesh.flatten()
z_flat = z_mesh.flatten() 

# (x - x_0)
x_minus_x0_x_flat = x_flat - x_0[0, 0]
x_minus_x0_y_flat = y_flat - x_0[1, 0]
x_minus_x0_z_flat = z_flat - x_0[2, 0]

# Prepare for the dot product
x_minus_x0_array = py.array(
    [
        x_minus_x0_x_flat,
        x_minus_x0_y_flat,
        x_minus_x0_z_flat,
    ]
)

# n dot (x - x_0)
dot_product = py.array(py.dot(n.T, x_minus_x0_array)).flatten()

# Prepare for the 3D axis
fig = py.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection='3d')

# Scatter plot
# https://matplotlib.org/gallery/mplot3d/scatter3d.html
# http://jakevdp.github.io/mpl_tutorial/tutorial_pages/tut5.html
scatter = ax.scatter(x_flat, 
                     y_flat, 
                     z_flat, c=dot_product, cmap='jet')

# Indicate x_0
ax.plot((0, x_0[0, 0]), (0, x_0[1, 0]), (0, x_0[2, 0]), label='$\\mathbf{x_0}$')
# Indicate n
ax.plot((x_0[0, 0], x_0[0, 0]+n[0, 0]), 
        (x_0[1, 0], x_0[1, 0]+n[1, 0]), 
        (x_0[2, 0], x_0[2, 0]+n[2, 0]), 
        label='$\\mathbf{n}$', linewidth=3)

# Legend
py.legend(loc=0)

# Which color of point represent which value?
py.colorbar(scatter)

# Title of the plot
py.title(r'$\mathbf{n} \cdot \left(\mathbf{x} - \mathbf{x}_0 \right)$')<jupyter_output><empty_output><jupyter_text>내적 값 0인 점의 집합이 해당 평면이다.The set of points with the inner product value 0 is the plane.  Final Bell마지막 종<jupyter_code># stackoverfow.com/a/24634221
import os
os.system("printf '\a'");<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18876712328767123, 'fraction_numerical': 0.05452054794520548, 'mean_word_length': 3.7850589777195283, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '104937', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1829, 'n_tokens_neox': 1838, 'n_words': 410, 'path': '40_linear_algebra_1/30_3D_line_plane.ipynb', 'repo_name': 'kangwonlee/2009eca-nmisp-template', 'size': '3650'}