# Euclidean distance

The Euclidean distance between geometric objects can be measured by using commutators to calculate homogeneous magnitudes.

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 Illustration
$$\left\Vert[\mathbf p, \mathbf q]^{\Large\unicode{x27C7}}_-\right\Vert_\unicode{x25CF} + \left\Vert[\mathbf p, \mathbf q]^{\Large\unicode{x27C7}}_+\right\Vert_\unicode{x25CB} = \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|{\large\unicode{x1D7D9}}$$ Distance $$d$$ between points $$\mathbf p$$ and $$\mathbf q$$.
$$\left\Vert[\mathbf p, \mathbf L]^{\Large\unicode{x27C7}}_-\right\Vert_\unicode{x25CF} + \left\Vert[\mathbf p, \mathbf L]^{\Large\unicode{x27C7}}_+\right\Vert_\unicode{x25CB} = \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} + {\large\unicode{x1D7D9}}\sqrt{p_w^2(v_x^2 + v_y^2 + v_z^2)}$$ Perpendicular distance $$d$$ between point $$\mathbf p$$ and line $$\mathbf L$$.
$$\left\Vert[\mathbf p, \mathbf f]^{\Large\unicode{x27C7}}_-\right\Vert_\unicode{x25CF} + \left\Vert[\mathbf p, \mathbf f]^{\Large\unicode{x27C7}}_+\right\Vert_\unicode{x25CB} = |p_xf_x + p_yf_y + p_zf_z + p_wf_w| + {\large\unicode{x1D7D9}}\sqrt{p_w^2(f_x^2 + f_y^2 + f_z^2)}$$ Perpendicular distance $$d$$ between point $$\mathbf p$$ and plane $$\mathbf f$$.
$$\left\Vert[\mathbf L, \mathbf K]^{\Large\unicode{x27C7}}_+\right\Vert_\unicode{x25CF} + \left\Vert[\mathbf L, \mathbf K]^{\Large\unicode{x27C7}}_-\right\Vert_\unicode{x25CB} = |v_xn_x + v_yn_y + v_zn_z + w_xm_x + w_ym_y + w_zm_z| + {\large\unicode{x1D7D9}}\sqrt{(v_yw_z - v_zw_y)^2 + (v_zw_x - v_xw_z)^2 + (v_xw_y - v_yw_x)^2}$$ Perpendicular distance $$d$$ between lines $$\mathbf K$$ and $$\mathbf L$$.