# Euclidean distance

The Euclidean distance between geometric objects can be measured using commutators and the weight norm.

The following table lists formulas for Euclidean distances between the main types of geometric objects in the 4D projective geometric algebra $$\mathcal G_{3,0,1}$$. These formulas are general and do not require the geometric objects to be unitized. Most of them become simpler if unitization can be assumed.

The points, lines, and planes appearing in the distance formulas are defined as follows:

$$\mathbf p = p_x \mathbf e_1 + p_y \mathbf e_2 + p_z \mathbf e_3 + p_w \mathbf e_4$$
$$\mathbf q = q_x \mathbf e_1 + q_y \mathbf e_2 + q_z \mathbf e_3 + q_w \mathbf e_4$$
$$\mathbf K = w_x \mathbf e_{41} + w_y \mathbf e_{42} + w_z \mathbf e_{43} + n_x \mathbf e_{23} + n_y \mathbf e_{31} + n_z \mathbf e_{12}$$
$$\mathbf L = v_x \mathbf e_{41} + v_y \mathbf e_{42} + v_z \mathbf e_{43} + m_x \mathbf e_{23} + m_y \mathbf e_{31} + m_z \mathbf e_{12}$$
$$\mathbf f = f_x \mathbf e_{234} + f_y \mathbf e_{314} + f_z \mathbf e_{124} + f_w \mathbf e_{321}$$
Formula Interpretation
$$\dfrac{\left\Vert\mathbf p \mathbin{\unicode{x27D1}\kern{-0.2em}\unicode{x2212}\kern{-0.2em}\unicode{x27D1}} \mathbf q\right\Vert_\unicode{x25CB}}{\left\Vert\mathbf p \mathbin{\unicode{x27C7}\kern{-0.2em}\unicode{x2B}\kern{-0.2em}\unicode{x27C7}} \mathbf q\right\Vert_\unicode{x25CB}} = \dfrac{\sqrt{(q_xp_w - p_xq_w)^2 + (q_yp_w - p_yq_w)^2 + (q_zp_w - p_zq_w)^2}}{|p_wq_w|}$$ Distance between points $$\mathbf p$$ and $$\mathbf q$$.
$$\dfrac{\left\Vert\mathbf p \mathbin{\unicode{x27D1}\kern{-0.2em}\unicode{x2212}\kern{-0.2em}\unicode{x27D1}} \mathbf L\right\Vert_\unicode{x25CB}}{\left\Vert\mathbf p \mathbin{\unicode{x27C7}\kern{-0.2em}\unicode{x2B}\kern{-0.2em}\unicode{x27C7}} \mathbf L\right\Vert_\unicode{x25CB}} = \dfrac{\sqrt{(v_yp_z - v_zp_y + m_xp_w)^2 + (v_zp_x - v_xp_z + m_yp_w)^2 + (v_xp_y - v_yp_x + m_zp_w)^2}}{|p_w|\sqrt{v_x^2 + v_y^2 + v_z^2}}$$ Perpendicular distance between point $$\mathbf p$$ and line $$\mathbf L$$.
$$\dfrac{\left\Vert\mathbf p \mathbin{\unicode{x27D1}\kern{-0.2em}\unicode{x2B}\kern{-0.2em}\unicode{x27D1}} \mathbf f\right\Vert_\unicode{x25CB}}{\left\Vert\mathbf p \mathbin{\unicode{x27C7}\kern{-0.2em}\unicode{x2212}\kern{-0.2em}\unicode{x27C7}} \mathbf f\right\Vert_\unicode{x25CB}} = \dfrac{|p_xf_x + p_yf_y + p_zf_z + p_wf_w|}{|p_w|\sqrt{f_x^2 + f_y^2 + f_z^2}}$$ Perpendicular distance between point $$\mathbf p$$ and plane $$\mathbf f$$.
$$\dfrac{\left\Vert\mathbf K \mathbin{\unicode{x27D1}\kern{-0.2em}\unicode{x2B}\kern{-0.2em}\unicode{x27D1}} \mathbf L\right\Vert_\unicode{x25CB}}{\left\Vert\mathbf K \mathbin{\unicode{x27C7}\kern{-0.2em}\unicode{x2212}\kern{-0.2em}\unicode{x27C7}} \mathbf L\right\Vert_\unicode{x25CB}} = \dfrac{|v_xn_x + v_yn_y + v_zn_z + w_xm_x + w_ym_y + w_zm_z|}{\sqrt{(v_yw_z - v_zw_y)^2 + (v_zw_x - v_xw_z)^2 + (v_xw_y - v_yw_x)^2}}$$ Perpendicular distance between lines $$\mathbf K$$ and $$\mathbf L$$.