Being $\bar{\mathbf{x}} \in \mathbb{R}^3$ a point and $S =\{\mathbf{x}\}_{i=1}^N \in \mathbb{R}^3$ a sample of N points. I am looking for a simple algorithm to determine the nearest point in $S$ in respect to $\bar{x}$ along a specific direction $\mathbf{\hat{u}}$


  • $\begingroup$ What do you mean nearest point along a specific direction? Is $S$ an unstructured point cloud? If yes, your definition is ill-posed. There might be no point at all in $\hat{\mathbf{u}}$ direction with respect to $\bar{\mathbf{x}}$. $\endgroup$ Commented Oct 23, 2019 at 21:30
  • $\begingroup$ Do you accept an approximate solution? Well, if $S$ is an unstructured point cloud, which I assume it is indeed due to your notation of labeling points by their IDs, you need to accept just an approximate solution here. Please clarify a bit more here. $\endgroup$ Commented Oct 23, 2019 at 21:33

1 Answer 1


The question really boils down to how far two points $x,y$ are from each other in direction $u$. This is easily answered: You need to compute the component of $y-x$ onto $u$, i.e., their (signed) distance in direction $u$ is $\frac{(y-x)\cdot u}{\|u\|}$.

For your point cloud, you can then compute for each $i$ the (unsigned) distance $$ d_i = \frac{(\bar x-x_i)\cdot u}{\|u\|} $$ and then you just need to find that $i$ for which $d_i$ is smallest.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.