Python과 함께하는 고등학교 수학: 이차곡선

발행: (2026년 1월 9일 오전 10:37 GMT+9)
4 분 소요
원문: Dev.to

It looks like only the source line was provided. Could you please share the full text you’d like translated? Once I have the content, I’ll translate it into Korean while keeping the source link and formatting unchanged.

원뿔곡선 개요

원, 포물선, 타원, 그리고 쌍곡선은 원뿔곡선의 네 가지 유형으로, 평면이 이중 원뿔을 가로지를 때 나타나는 곡선입니다.
결과 곡선의 형태는 절단 평면과 원뿔 축 사이의 각도에 따라 달라집니다.

원뿔곡선 종류표준형 (데카르트 방정식)
((x-h)^2 + (y-k)^2 = r^2)
포물선(y = a(x-h)^2 + k) (or (x = a(y-k)^2 + h))
타원(\displaystyle \frac{(x-h)^2}{a^2} + \frac{(y-k)^2}{b^2} = 1)
쌍곡선(\displaystyle \frac{(x-h)^2}{a^2} - \frac{(y-k)^2}{b^2} = 1) (or the swapped signs)

이 프로그램이 보여주는 내용

아래의 인터랙티브 프로그램은 원뿔, 절단 평면, 그리고 그 결과로 얻어지는 2‑D 단면을 시각화합니다.

  • 오른쪽 플롯에 있는 범례는 단면의 명시적인 방정식을 표시합니다.
  • 슬라이더를 사용해 절단 각도 β를 바꾸면 곡선이 원, 타원, 포물선, 그리고 쌍곡선으로 변하는 모습을 확인할 수 있습니다.

이 코드는 AI의 도움을 받아 생성되었으며, 단계별 교실 수업용이라기보다 탐구용으로 의도되었습니다.

실시간 노트북

# Initial setup for displaying Japanese characters in graphs
!pip install -q japanize-matplotlib
import japanize_matplotlib  # Enables proper display of Japanese text in plots

import numpy as np
import matplotlib.pyplot as plt
from ipywidgets import interact, FloatSlider

def draw_conic_with_equation(beta_deg):
    alpha_deg = 45                     # Fixed cone half‑angle
    alpha = np.radians(alpha_deg)
    beta = np.radians(beta_deg)
    d = 0.5                            # Plane offset from the origin

    fig = plt.figure(figsize=(14, 6))

    # --- Left: 3D cone and cutting plane ---
    ax1 = fig.add_subplot(121, projection='3d')
    r = np.linspace(0, 2, 40)
    theta = np.linspace(0, 2 * np.pi, 40)
    R, THETA = np.meshgrid(r, theta)
    X_cone = R * np.cos(THETA)
    Y_cone = R * np.sin(THETA)
    Z_cone_up = R / np.tan(alpha)
    Z_cone_down = -R / np.tan(alpha)

    X_p = np.linspace(-2, 2, 10)
    Y_p = np.linspace(-2, 2, 10)
    XP, YP = np.meshgrid(X_p, Y_p)
    ZP = XP * np.tan(beta) + d

    ax1.plot_surface(X_cone, Y_cone, Z_cone_up, alpha=0.15, color='cyan')
    ax1.plot_surface(X_cone, Y_cone, Z_cone_down, alpha=0.15, color='cyan')
    ax1.plot_surface(XP, YP, ZP, alpha=0.4, color='orange')
    ax1.set_title("3D View")

    # --- Right: 2D cross section ---
    ax2 = fig.add_subplot(122)

    # Expanded equation of the cross section:
    # y^2 = (tan^2(beta) - 1)·x^2 + (2·d·tan(beta))·x + d^2
    x_range = np.linspace(-4, 4, 1000)
    tan_b = np.tan(beta)
    y_sq = (x_range * tan_b + d)**2 - x_range**2

    valid = y_sq >= 0
    x_plot = x_range[valid]
    y_plot = np.sqrt(y_sq[valid])

    # Coefficients for legend display
    A = tan_b**2 - 1
    B = 2 * d * tan_b
    C = d**2
    eq_label = rf'$y^2 = ({A:.2f})x^2 + ({B:.2f})x + {C:.2f}$'

    ax2.plot(x_plot, y_plot, color='blue', linewidth=2, label=eq_label)
    ax2.plot(x_plot, -y_plot, color='blue', linewidth=2)

    # Determine conic type based on angle β
    if beta_deg == 0:
        shape_type = "Circle"
    elif beta_deg < alpha_deg:
        shape_type = "Ellipse"
    elif beta_deg == alpha_deg:
        shape_type = "Parabola"
    else:
        shape_type = "Hyperbola"

    ax2.set_title(f"2D Cross Section: {shape_type}")
    ax2.set_xlabel('x')
    ax2.set_ylabel('y')
    ax2.set_xlim(-3, 3)
    ax2.set_ylim(-3, 3)
    ax2.grid(True)
    ax2.axhline(0, color='black', lw=1)
    ax2.axvline(0, color='black', lw=1)

    # Legend in the lower‑left corner
    ax2.legend(loc='lower left', fontsize=10)

    plt.tight_layout()
    plt.show()

# Interactive slider for the cutting angle β
interact(
    draw_conic_with_equation,
    beta_deg=FloatSlider(min=0, max=85, step=1, value=0, description='Angle β')
)
Back to Blog

관련 글

더 보기 »

안녕, 뉴비 여기요.

안녕! 나는 다시 S.T.E.M. 분야로 돌아가고 있어. 에너지 시스템, 과학, 기술, 공학, 그리고 수학을 배우는 것을 즐겨. 내가 진행하고 있는 프로젝트 중 하나는...