Let’s say we have a hand made of five fingers and we want to know if it’s intersecting a shape. Assume we can detect where the five fingertips intersect with the shape. And below we will analyse the distance of fingertips to a cuboid.
Distance to Cuboid
Assume we have two lists of 3D points with same length, in which ${\proselabel{HandToShapeDistance}{{ps}}}$ includes the start points of eight edges, and ${\proselabel{HandToShapeDistance}{{pe}}}$ includes all end points of edges. The following formula ${\prosedeflabel{HandToShapeDistance}{{f}}}$ calculates the distance from one point to an edge in 3 conditions: closest to start or end point, or perpendicular to the edge. ${\prosedeflabel{HandToShapeDistance}{{ps_i}}}$ is the start point of edge ${\prosedeflabel{HandToShapeDistance}{{i}}}$ , and ${\prosedeflabel{HandToShapeDistance}{{pe_i}}}$ represents the 3D position of endpoint of edge ${\prosedeflabel{HandToShapeDistance}{{i}}}$ . ${\prosedeflabel{HandToShapeDistance}{{V_j}}}$ represents the 3D position of fingertip ${\prosedeflabel{HandToShapeDistance}{{j}}}$ . ${\prosedeflabel{HandToShapeDistance}{{A}}}$ is the matrix storing the distance between fingertips to edges ${\prosedeflabel{HandToShapeDistance}{{j}}}$ . ${\prosedeflabel{HandToShapeDistance}{{f}}}$ represents the 3D position of fingertip ${\prosedeflabel{HandToShapeDistance}{{j}}}$ .
$$\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
\begin{align*}
\idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'f', 'HandToShapeDistance', 'def', false, '')", "id":"HandToShapeDistance-f", "sym":"f", "func":"HandToShapeDistance", "localFunc":"", "type":"def", "case":"equation"} }{ {\mathit{f}} }\left( \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'ps_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-ps_i", "sym":"ps_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {ps_i} },\idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'pe_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-pe_i", "sym":"pe_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {pe_i} },\idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'V_j', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-V_j", "sym":"V_j", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {V_j} } \right) & = \begin{cases} \left\|\idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'V_j', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-V_j", "sym":"V_j", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {V_j} } - \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'ps_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-ps_i", "sym":"ps_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {ps_i} }\right\| & \text{if } \left( \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'pe_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-pe_i", "sym":"pe_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {pe_i} } - \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'ps_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-ps_i", "sym":"ps_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {ps_i} } \right) \cdot \left( \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'V_j', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-V_j", "sym":"V_j", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {V_j} } - \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'ps_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-ps_i", "sym":"ps_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {ps_i} } \right) > 0 \\\left\|\idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'V_j', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-V_j", "sym":"V_j", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {V_j} } - \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'pe_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-pe_i", "sym":"pe_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {pe_i} }\right\| & \text{if } \left( \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'ps_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-ps_i", "sym":"ps_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {ps_i} } - \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'pe_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-pe_i", "sym":"pe_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {pe_i} } \right) \cdot \left( \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'V_j', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-V_j", "sym":"V_j", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {V_j} } - \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'pe_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-pe_i", "sym":"pe_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {pe_i} } \right) > 0 \\ \frac{\left( \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'pe_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-pe_i", "sym":"pe_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {pe_i} } - \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'ps_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-ps_i", "sym":"ps_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {ps_i} } \right) \cdot \left( \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'V_j', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-V_j", "sym":"V_j", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {V_j} } - \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'ps_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-ps_i", "sym":"ps_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {ps_i} } \right)}{\left\|\idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'pe_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-pe_i", "sym":"pe_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {pe_i} } - \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'ps_i', 'HandToShapeDistance', 'use', true, 'f')", "id":"HandToShapeDistance-ps_i", "sym":"ps_i", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {ps_i} }\right\|} & \text{otherwise} \end{cases}\\\eqlabel{ {"onclick":"event.stopPropagation(); onClickEq(this, 'HandToShapeDistance', ['V_j', 'pe_i', 'ps_i', 'f'], true, 'f', ['ps_i', 'pe_i', 'V_j'], 'ZihgcHNfaWAsIGBwZV9pYCwgYFZfamApID0geyDigJZgVl9qYCAtIGBwc19pYOKAliBpZiAoYHBlX2lgIC0gYHBzX2lgKSDii4UgKGBWX2pgIC0gYHBzX2lgKSA-IDAKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIOKAlmBWX2pgIC0gYHBlX2lg4oCWIGlmIChgcHNfaWAgLSBgcGVfaWApIOKLhSAoYFZfamAgLSBgcGVfaWApID4gMAoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGBwZV9pYCAtIGBwc19pYCnii4UgKGBWX2pgIC0gYHBzX2lgKS_igJZgcGVfaWAgLSBgcHNfaWDigJYgIG90aGVyd2lzZSB3aGVyZSBgVl9qYCwgYHBzX2lgLCBgcGVfaWAg4oiIIOKEnV4zICAsIGksaiDiiIgg4oSd');"} }{}
\idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'A', 'HandToShapeDistance', 'def', false, 'f')", "id":"HandToShapeDistance-A_ij", "sym":"A", "func":"HandToShapeDistance", "localFunc":"f", "type":"def", "case":"equation"} }{ {\mathit{A}} }_{\mathit{i},\mathit{j}} & = \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'f', 'HandToShapeDistance', 'use', false, 'f')", "id":"HandToShapeDistance-f", "sym":"f", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {\mathit{f}} }\left( \idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'ps', 'HandToShapeDistance', 'use', false, 'f')", "id":"HandToShapeDistance-ps", "sym":"ps", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {\mathit{ps}} }_{ \mathit{i} },\idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'pe', 'HandToShapeDistance', 'use', false, 'f')", "id":"HandToShapeDistance-pe", "sym":"pe", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {\mathit{pe}} }_{ \mathit{i} },\idlabel{ {"onclick":"event.stopPropagation(); onClickSymbol(this, 'V', 'HandToShapeDistance', 'use', false, 'f')", "id":"HandToShapeDistance-V", "sym":"V", "func":"HandToShapeDistance", "localFunc":"f", "type":"use", "case":"equation"} }{ {\mathit{V}} }_{ \mathit{j} } \right)\\\eqlabel{ {"onclick":"event.stopPropagation(); onClickEq(this, 'HandToShapeDistance', ['ps', 'pe', 'f', 'V', 'A'], false, [], [], 'QV9paiA9IGYocHNfaSwgcGVfaSwgVl9qKQ==');"} }{}
\end{align*}
\tag{1}\label{1}$$