How to pick points inside a circle in OpenGL?

Viewed 239

For a point cloud, I am trying to pick points inside a circle(which represent the mouse's position), just like this.

Currently I do this work by:

  1. cast a ray from the circle center.
  2. calculate the closest point to the ray.
  3. calculate the distance between closest point and other points in this point cloud, and then select those points which distance < r(r represent the radius of the circle).

But I found some problem with this method,

  1. sometimes the closest point to the ray is not what I want, since a point cloud have two side, front side and back side. Just like the following image, what I expect is the blue one, but the closest point to the ray might be the red one.
  2. this method is so slow. enter image description here

Is there a better way to do this?

0 Answers
Related