View Full Version : creating non overlaping triangles?

sidhu

10-02-2009, 08:00 AM

hello,

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..

regards

Sid

ZbuffeR

10-02-2009, 08:29 AM

Please do not cross post.

This has nothing to do with opengl.

Don't expect people to do your homework.

sidhu

10-02-2009, 08:57 AM

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][2]=PointArray[0][0];

PointArray[i][3]=PointArray[0][1];

PointArray[i][4]=dist(0,i);

printf("%0.4f\n",dist(0,i));

//printf("%0.4f\n", PointArray[i][4]);

PointArray[i][5]=PointArray[1][0];

PointArray[i][6]=PointArray[1][1];

PointArray[i][7]=dist(1,i);

internalcheck(i);

for(int j=0;j<i;j++)

{ if(j>1&&dist(i,j)<PointArray[i][7])

{

PointArray[i][5]=PointArray[j][0];

PointArray[i][6]=PointArray[j][1];

PointArray[i][7]=dist(i,j);

internalcheck(i);

}

}

}

}

void internalcheck(int i)

{ if( PointArray[i][7]<PointArray[i][4])

{

swap1(i,2,5);

swap1(i,3,6);

swap1(i,4,7);

}

}

ZbuffeR

10-02-2009, 12:11 PM

"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'.

sidhu

10-04-2009, 01:26 AM

thnx for the replies.. i ll try intersection detection.. :)

sidhu

10-04-2009, 06:36 PM

can any1 help me with implementation of "Delauney Triangulation" into opengl..

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.

rakesh_thp

10-07-2009, 02:24 AM

hi sidhu..

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

Thanks

Dj3hut1

10-07-2009, 07:36 AM

Hello,

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

http://algoria.de/files/PlanarGraph.zip

Source code is inclusive.

You can start the program from command line with 'java PlanarGraph'

dj3hut1

rakesh_thp

10-12-2009, 03:06 AM

Hi DJ...

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

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.