creating non overlaping triangles?


I have been tryin hard to create triangles from given vertices( that are taken from mouse input) but the thing is the triangles “shouldn’t have any of its edges overlapped”.
Can any1 help me…


Please do not cross post.
This has nothing to do with opengl.
Don’t expect people to do your homework.

hey i m not expectin some1 to do it… I was workin on creating manually created triangular meshes and i was stuck.
The code i wrote worked but it had major flaws and i thought there shud be some easier way/approach to do it… thts why i posted it here.(i dodnt know if algoriths section or newbie section is apt for this post…so i posted in both)
“Don’t expect people to do your homework.”-> that was harsh!

anyways… i can provide my full code if any1 has any idea on wht i m talkin abt…

basically I m saving the nodes into an array “PointArray[][8]”
PointArray[i][]… i denotes the vertices…
PointArray[i][0] current point x co-rdinate
PointArray[i][1] current pt y cordinate
PointArray[i][2] expected next point 1 x co-ordi
PointArray[i][3] y
PointArray[i][4] least distance from all other vertices
PointArray[i][5] expected nx pt2 x
PointArray[i][6] y
PointArray[i][7] 2nd least dist

i update all the nodes when new pt is inserted…
void updatenodes()
for(int i=0;i<NumPts;i++)
{ if(i>1)
{//init distance to 1st n 2nd vertices
", PointArray[i][4]);

 for(int j=0;j&lt;i;j++)
        {  if(j&gt;1&&dist(i,j)&lt;PointArray[i][7])


void internalcheck(int i)
{ if( PointArray[i][7]<PointArray[i][4])

“shouldn’t have any of its edges overlapped”
You need something to test for segment to triangle intersection, search that in any websearch engin should return useful results.
Do you need 2D or 3D collision test ?

Triangulation of a random set of points is not trivial. In fact it’s a classic problem in the field of computational geometry. For starters, google ‘Delauney Triangulation’.

thnx for the replies… i ll try intersection detection… :slight_smile:

can any1 help me with implementation of “Delauney Triangulation” into opengl…

Sorry, can’t do much more than point you in that direction. I’ve never coded it up myself. If you search around the Internet, you may find some free code that you could use. The alternative, albeit not trivial, would be to read descriptions of the algorithm and code it up yourself.

hi sidhu…

Did u try out triangle segment intersection detection…?? if so please let me know…



i’ve coded something similar in Java to find a planar graph ( triangle net ) for a random set of nodes in 2D :

Source code is inclusive.
You can start the program from command line with ‘java PlanarGraph’


Hi DJ…

I am out of knowledge with JAVA… So can u upload ur algorithm…?? That will be so kind enough of u…