<p>I am trying to solve the current problem using GPU capabilities: "given a point cloud P and an oriented plane described by a point and a normal (Pp, Np) return the points in the cloud which lye at a distance equal or less than EPSILON from the plane".</p>

<p>Talking with a colleague of mine I converged toward the following solution:</p>

<p>1) prepare a vertex buffer of the points with an attached texture coordinate such that every point has a different vertex coordinate
2) set projection status to orthogonal
3) rotate the mesh such that the normal of the plane is aligned with the -z axis and offset it such that x,y,z=0 corresponds to Pp
4) set the z-clipping plane such that z:[-EPSILON;+EPSILON]
5) render to a texture
6) retrieve the texture from the graphic card
7) read the texture from the graphic card and see what points were rendered (in terms of their indexes), which are the points within the desired distance range.</p>

<p>Now the problems are the following:
q1) Do I need to open a window-frame to be able to do such operation? I am working within MATLAB and calling MEX-C++. By experience I know that as soon as you open a new frame the whole suit crashes miserably!
q2) what's the primitive to give a GLPoint a texture coordinate?
q3) I am not too clear how the render to a texture would be implemented? any reference, tutorial would be awesome...
q4) How would you retrieve this texture from the card? again, any reference, tutorial would be awesome...</p>

<p>I am on a tight schedule, thus, it would be nice if you could point me out the names of the techniques I should learn about, rather to the GLSL specification document and the OpenGL API as somebody has done. Those are a tiny bit too vague answers to my question.</p>

<p>Thanks a lot for any comment.</p>

<p>p.s.
Also notice that I would rather not use any resource like CUDA if possible, thus, getting something which uses
as much OpenGL elements as possible without requiring me to write a new shader. </p>

<p>Note: cross posted at
<a href="http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&amp;Number=245911#Post245911" rel="nofollow noreferrer">http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&amp;Number=245911#Post245911</a></p>

[{'answer_id': 77543, 'author': 'Sarien', 'author_id': 1994377, 'author_profile': 'https://Stackoverflow.com/users/1994377', 'pm_score': 0, 'selected': False, 'text': '<p>Ok first as a little disclaimer: I know nothing about 3D programming.</p>\n\n<p>Now my purely mathematical idea:</p>\n\n<p>Given a plane by a normal N (of unit length) and a distance L of the plane to the center (the point [0/0/0]). The distance of a point X to the plane is given by the scalar product of N and X minus L the distance to the center. Hence you only have to check wether</p>\n\n<p>|n . x - L| &lt;= epsilon</p>\n\n<p>. being the scalar product and | | the absolute value</p>\n\n<p>Of course you have to intersect the plane with the normal first to get the distance L.</p>\n\n<p>Maybe this helps.</p>\n'}, {'answer_id': 81165, 'author': 'Sarien', 'author_id': 1994377, 'author_profile': 'https://Stackoverflow.com/users/1994377', 'pm_score': 1, 'selected': False, 'text': '<p>It\'s simple:\nLet n be the normal of the plane and x be the point.</p>\n\n<pre><code>n_u = n/norm(n)         //this is a normal vector of unit length\nd   = scalarprod(n,x)   //this is the distance of the plane to the origin\n\nfor each point p_i\n    d_i = abs(scalarprod(p_i,n) - d)  //this is the distance of the point to the plane\n</code></pre>\n\n<p>Obviously "scalarprod" means "scalar product" and "abs" means "absolute value".\nIf you wonder why just read the article on scalar products at wikipedia.</p>\n'}, {'answer_id': 93928, 'author': 'thing2k', 'author_id': 3180, 'author_profile': 'https://Stackoverflow.com/users/3180', 'pm_score': 0, 'selected': False, 'text': "<p>I have one question for Andrea Tagliasacchi, Why?</p>\n\n<p>Only if you are looking at 1000s of points and possible 100s of planes, would there would be any benefit from using the method outlined. As apposed to dot producting the point and plane, as outlined my Corporal Touchy.</p>\n\n<p>Also due to the finite nature of pixels you'll often find two or more points will project to the same pixel in the texture. </p>\n\n<p>If you still want to do this, I could work up a sample glut program in C++, but how this would help with MATLAB I don't know, as I'm unfamiliar with it.</p>\n"}, {'answer_id': 116939, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>IT seems to me you should be able to implement something similar to Corporal Touchy\'s method a a vertex program rather than in a for loop, right? Maybe use a C API to GPU programming, such as <a href="http://www.nvidia.com/object/cuda_what_is.html" rel="nofollow noreferrer">CUDA</a>?</p>\n'}]
['https://Stackoverflow.com/questions/77258', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']