Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Jallen

Center of a triangle

This topic is 6362 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Anyone know of a quick way to find the center of an arbitrary triangle? Thanks, Jason A. --- I write code. DelphiGL (http://delphigl.cfxweb.net)

Share this post


Link to post
Share on other sites
Advertisement
I''d say find the change in x and go halfway...then find the change in y and go halfway...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You just add the vertices together and divide by three...

  

// v1, v2 and v3 are the vertices.


Vertex center;

center.x = (v1.x + v2.x + v3.x) * 0.3333333;
center.y = (v1.y + v2.y + v3.y) * 0.3333333;
center.z = (v1.z + v2.z + v3.z) * 0.3333333;



but if you are just sorting them based on their center points, you don''t have to do the multiplly.

Share this post


Link to post
Share on other sites
There are quite a selection of "centers of triangles"...

Taking the average of the x values and the average of the y values will only give you the center of gravity of the three corners. If you want the center of gravity of the triangle, you''ll need some more work. It''s at the point where the lines joining corners to the midpoint of the opposite sides all meet - but I can''t be bothered to do the math right now.

Share this post


Link to post
Share on other sites
yeah, i had posted the averaging solution in his other identical thread of his. i think that''s an okay way.

a2k

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!