[Math] Distance between Point and Plane : 점과 직선의 거리

2022. 5. 19. 19:01·.../Math
728x90
728x90

점과 직선의 거리

Position Vector $\textbf{x}$ (아래 그림에서 Point $Q$에 대한 Position Vector)와

$\textbf{n}\cdot \textbf{p}+b=0$을 만족하는 Position Vector $\textbf{p}$들로 구성되는 평면(Plane $P$)과의

Distance(거리 , $d$)는 다음과 같음.


$$d=\dfrac{|\textbf{n}\cdot\textbf{x}+b|}{\|\textbf{n}\|}$$

 

where

  • $\|\textbf{n}\|$ : $\textbf{n}$의 L-2 norm (or magnitude, length)임. (엄밀하게 쓰면, $\|\textbf{n}\|_2$)

증명

Point $Q$와 Plane $P$와의 거리는 Plane Equation과 Projection을 이용하여 구할 수 있음.

  • 2022.05.19 - [.../Math] - [Math] Plane equation : 평면의 방정식
  • 2022.05.19 - [.../Math] - [Math] Orthogonal Projection (정사영)

  • 옆의 그림을 기반으로 설명하면 다음과 같음.
  • 우선
    Plane $P$에 속하는 임의의 Point $P_0$를 선택한다.
    이때 Point $P_0$의 Position Vector는 $\textbf{p}_0$임.
  • 그림과 같이,
    Point $Q$의 Position Vector가 $\textbf{x}$라고 하면,
    Point $P_0$에서 시작해서 Point $Q$에서 끝나는 Difference Vector $\textbf{x}-\textbf{p}_0$가 구해짐.
  • 우리가 구하고자 하는 Distance(거리)는 결국
    Difference Vector $\textbf{x}-\textbf{p}_0$를
    Plane $P$의 Normal Vector인 $\textbf{n}$에 Projection을 시킨 Vector $\textbf{h}$의 Magnitude 에 해당함.

Projection의 공식에 따라,

  • $\textbf{h}=\text{Projection}_{\textbf{n}}(\textbf{x}-\textbf{p}_0)=\dfrac{(\textbf{x}-\textbf{p}_0)\cdot \textbf{n}}{\|\textbf{n}\|^2}\textbf{n}$ 이 성립하고,
  • Point $P_0$가 Plane $P$에 속하는 점이므로 Plane Equation, $\textbf{n}\cdot\textbf{p}_0+b=0$가 성립.

 

이를 이용하여 다음과 같이 전개 가능함.
$$\begin{aligned}\|\textbf{h}\|&=\left\|\dfrac{(\textbf{x}-\textbf{p}_0)\cdot \textbf{n}}{\|\textbf{n}\|^2}\textbf{n}\right\|\\&=\left\|\dfrac{\textbf{n} \cdot(\textbf{x}-\textbf{p}_0)}{\|\textbf{n}\|^2}\textbf{n}\right\|\\&=\left\|\dfrac{(\textbf{n}\cdot\textbf{x} -\textbf{n}\cdot\textbf{p}_0)}{\|\textbf{n}\|^2}\textbf{n}\right\|\\&=\left\|\dfrac{(\textbf{n}\cdot\textbf{x} - (-b))}{\|\textbf{n}\|^2}\textbf{n}\right\|\\&=\left\|\dfrac{(\textbf{n}\cdot\textbf{x} +b)}{\|\textbf{n}\|^2}\textbf{n}\right\|\\&=\dfrac{|\textbf{n}\cdot\textbf{x} +b|}{\|\textbf{n}\|^2}\|\textbf{n}\|\\&=\dfrac{|\textbf{n}\cdot\textbf{x} +b|}{\|\textbf{n}\|}\end{aligned}$$


응용

  • Decision Boundary를 이루는 Hyper-Plane 과의 특정 feature vector의 거리를 구할 수 있음.
  • 위의 공식은 Multi-Dimensional Vector에서 사용가능함: 설명은 3D Vector Space에서 했지만...
  • SVM 등의 전개에서 margin을 극대화하는 Decision Boundary를 구하는데 이용됨.

예: Hard Margin SVM

Decision Boundary인 Hyper-plane의 식은 다음과 같음:

$$\textbf{w}^\top \textbf{x} +b = 0$$

  • 여기서 weight $\textbf{w}$와 bias $b$에 의해 결정경계를 나타내는 Hyper-plane이 결정됨.
  • 이는 두 클래스 (하나는 $t^{i}=-1$, 다른 하나는 $t^{(i)}=+1$을 만족)의 사이에 있는 margin을 최대화하여야 하며, 이는 다음의 optimization problem으로 나타내어짐. 
  • $t^{(i)}$에서 ${(i)}$는 exponent가 아닌, $i$번째 sample instance의 것임을 나타내는 superscript(위첨자)임.

$$ \underset{\textbf{w},b}{\text{argmax}} \frac{2}{\|\textbf{w}\|_2} \\ \text{subject to } t^{(i)}\left(\textbf{w}^\top \textbf{x}^{(i)} + b \right) \gt 1 \\ i = 1,2,\dots,m $$

  • support vector에서 $\textbf{w}^\top \textbf{x} +b = \pm 1$이 되도록 가정함.
  • 여기서 Decision Bounary와 support vector의 거리는 $\frac{1}{\|\textbf{w}\|_2}$ 이 되며, margin은 이 값의 2배임: $\text{margin}=\frac{2}{\|\textbf{w}\|_2}$
  • $t^{(i)}$는 $i$번째 instance의 label로 $\pm 1$의 값을 가짐: (positive class, negative class)
  • $m$은 전체 training dataset의 instance의 수임.
hard margin 은 모든 instance를 제대로 분류해야함.
soft margin에서는 slack variable을 도입하여 약간의 오차를 허용.
slack variable은 허용되는 오차의 크기를 정량화하는 음이 아닌 실수임.

'... > Math' 카테고리의 다른 글

[Math] Plane Equation : 평면의 방정식  (0) 2022.05.19
[Math] Orthogonal Projection (정사영)  (0) 2022.05.19
[ML] Softmax function  (0) 2022.05.12
[Math] Entropy 란 (평균정보량, 정보량의 기댓값)  (0) 2022.05.12
[Math] Cross Entropy  (0) 2022.05.12
'.../Math' 카테고리의 다른 글
  • [Math] Plane Equation : 평면의 방정식
  • [Math] Orthogonal Projection (정사영)
  • [ML] Softmax function
  • [Math] Entropy 란 (평균정보량, 정보량의 기댓값)
dsaint31x
dsaint31x
    반응형
    250x250
  • dsaint31x
    Dsaint31's blog
    dsaint31x
  • 전체
    오늘
    어제
    • 분류 전체보기 (740)
      • Private Life (13)
      • Programming (56)
        • DIP (104)
        • ML (26)
      • Computer (119)
        • CE (53)
        • ETC (33)
        • CUDA (3)
        • Blog, Markdown, Latex (4)
        • Linux (9)
      • ... (351)
        • Signals and Systems (103)
        • Math (172)
        • Linear Algebra (33)
        • Physics (42)
        • 인성세미나 (1)
      • 정리필요. (54)
        • 의료기기의 이해 (6)
        • PET, MRI and so on. (1)
        • PET Study 2009 (1)
        • 방사선 장해방호 (4)
        • 방사선 생물학 (3)
        • 방사선 계측 (9)
        • 기타 방사능관련 (3)
        • 고시 (9)
        • 정리 (18)
      • RI (0)
      • 원자력,방사능 관련법 (2)
  • 블로그 메뉴

    • Math
    • Programming
    • SS
    • DIP
  • 링크

    • Convex Optimization For All
  • 공지사항

    • Test
    • PET Study 2009
    • 기타 방사능관련.
  • 인기 글

  • 태그

    math
    Optimization
    SS
    signals_and_systems
    Probability
    Vector
    numpy
    fourier transform
    검사
    linear algebra
    opencv
    SIGNAL
    Python
    random
    signal_and_system
    Convolution
    인허가제도
    Programming
    function
    Term
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dsaint31x
[Math] Distance between Point and Plane : 점과 직선의 거리
상단으로

티스토리툴바