It is currently Thu Jul 27, 2017 1:40 pm




 Page 1 of 1 [ 2 posts ] 
Author Message
 Post subject: How to find the centroid of a triangle
PostPosted: Sun Jan 20, 2008 1:31 pm 

Joined: Fri Jan 04, 2008 2:11 pm
Posts: 72
i wan't a reiangle to rotate in it's axis ... here's the code

glTranslatef(??,??,-1.0);

glRotatef(_angle,1.0,1.0,1.0);

glBegin(GL_TRIANGLES);

glVertex3f(-0.2f, -0.20f,-1.0);
glVertex3f(0.2f, -0.2f,-1.0);
glVertex3f(0.0f, 0.2f,-1.0);

glEnd();


what i wan't to do is go to the center of the triangle and then rotate it so that it rotates on the axis/centroid , how do i find it??

using x_centroid=(x1+x2+x3)/3 , and same for y_centroid doesn't given the expected result , the center of rotation is far from the triangles axis


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Jan 20, 2008 7:51 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1102
Location: Ontario Canada
have a look at the scenegraph stuff in the game engine VMK series. If you take a look at the NodeTransform class, you will see that I added a "center" parameter. This is what you need. Using this parameter, you can specify where the center of your object is, and when you rotate, the object will then rotate about the specified center point.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron