   point on 3d triangle restart
  This is a link to the old thread- "point on 3d triangle"[Edited by - oops on May 19, 2010 10:05:51 AM]
  The values passed to the function should be:- The query point- The polygon normal- An array containing the polygon vertices, in order- The number of verticesThe polygon will need to be convex, and all polygons with which the function is used will need to be wound consistently (i.e. all CW or all CCW). If the function doesn't work given the winding that you're using, just change distance > 0.0f to distance < 0.0f.The function works by testing the point against a set of planes, one for each edge of the polygon. The planes are perpendicular to the plane in which the polygon lies, and each contains an edge from the polygon. The conditional checks to see what side of the plane the query point is on; if for any plane the point lies in the halfspace that is outside of the polygon, then it's outside of the 'polygon volume' as defined by the planes.   ;  I have to come up with points on its surface and inside its body.Ofcourse, the no. of points will be infinite. But I have to come up with some points. I have to write an alogorithm/pseudo code for that. I have been thinkin on it for a few days but cant find a way out, can u suggest me any ideas.Please help!![Edited by - oops on May 19, 2010 10:58:05 AM];Quote:Original post by oopsGiven a 3-d polygon(vertice co-ordinates of it), I have to come up with points on its surface and inside its body.Is this a homework assignment of some sort? (I'm just asking so that we can provide answers that are appropriate.)   ;  No its just a task   ;  It takes a polygon, and builds a set of infinite planes for each edges. Each planes are basically aligned with the edge, and the polygon normal. In short, the edge plane normal is the cross product of the edge and the polygon normal.If the point is front-facing any of those edge planes, then the point is outside. This is assuming a counter-clockwise convex polygon.   ;  @The OP: What happened to your original post? I don't see a link there, but in any case, not having the original post there makes the thread somewhat confusing and less useful for others who might read it :-|Anyway, if you want to generate uniformly distributed points on a polygon, I believe the following will work:1. Triangulate the polygon (e.g. by using a triangle fan).2. Pick a triangle randomly, with probability based on triangle area.3. Pick a random point on that triangle (Google 'random point on triangle' for details).   ;  To find points on a triangle, you convert to barycentric coordinates. For a triangle with vertices (A,B,C), you find:v0 = B-Av1 = C-APoints on the triangle can be expressed as:x = A + p*v0 + q*v1, where p > 0, q > 0 and p + q < 1.If you wanted to pick a point randomly, you could choose 'p' as a random number in the interval (0,1), and then choose 'q' as a random number in the interval (0,(1 - p)).   