after calculating the world space view vector from screen coordinates (using Click to zoom in WebGL), given an array of vertices, how do I find the closest intersecting point in world space?
Asked
Active
Viewed 272 times
1
-
2What are you finding difficult? Hint: the distance from a point to a line is given at http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html. – brainjam Jun 12 '11 at 19:25
1 Answers
0
You test each triangle against the ray. If the ray hits the triangle, and if it is closer then the closest known hit, you remember that point. Loop until you have no more triangles.
http://www.lighthouse3d.com/tutorials/maths/ray-triangle-intersection/
If you're using many triangles, that may be slow, so you could build a b-tree, octree, KD-tree or multi-resolution grid collision structure and first perform a broad phase collision before testing triangles contained in a leaf of the structure.

Florian Bösch
- 27,420
- 11
- 48
- 53