Jump to content
  • Advertisement
Sign in to follow this  
coder0xff

Triangle area

This topic is 4462 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

This topic is somewhat old I'm sure: Computing the area of a triangle in planar space (2 dimensional) is simple: for a triangle (x1,y1) - (x2, y2) - (x3, y3) V = 1/2((x2 - x1)(y3 - y1) - (x3 - x1)(y2 - y1)) //It is half the perp dot product of two edges The best I've come up with for 3 dimensional is this: //First get vectors for two edges of the triangle U.x=x2-x1: U.y=y2-y1: U.z=z2-z1 V.x=x3-x1: V.y=y3-y1: V.z=z3-z1 D.x = U.y*V.z-V.y*U.z: D.y = V.x*U.z-U.x*V.z: D.z = U.x*V.y-V.x*U.y Area = sqrt(D.x^2 + D.y^2 + D.z^2)/2; in notation A=|UxV|/2 Essentialy this is half the magnitude of the cross product of the two vectors. So my wonder is, why should we need to use a square root operation to obtain the area of a triangle in 3D.

Share this post


Link to post
Share on other sites
Advertisement
If you use the 3D form for a triangle in the XY plane, you will see that the result is:

Area = sqrt( Dz2 )/2 = Dz/2,

which is the same as the 2D form.


Share this post


Link to post
Share on other sites
I don't understand... the square root is of the sum of three seperate monomials... once there is adddition in the radicand square roots cannot be factored out. Is that what you meant?

Share this post


Link to post
Share on other sites
JohnBolton was assuming your original triangle was restricted to the XY plane, in which case the cross product vector would only have a non-zero Z component. Thus you can eliminate the square root because X and Y are automatically 0.

For the general case 3D, you indeed need to use a square root to find the length of the cross product vector, and divide it by 2.

Share this post


Link to post
Share on other sites
I interpreted your question as "Why is a square root needed in 3D but not in 2D?" I was trying to show that the 2D case does use square root, but since it reduces to the square root of a squared value, the two cancel each other out.

You can change a 3D problem into a 2D problem if you fix one of the axes to a constant value. In the XY plane (z = 0),
    D.x  = U.y*V.z-V.y*U.z = 0
D.y = V.x*U.z-U.x*V.z = 0
D.z = U.x*V.y-V.x*U.y
Area = sqrt(D.x^2 + D.y^2 + D.z^2)/2
= sqrt(0 + 0 + D.z^2)/2
= sqrt(D.z^2)/2
= D.z/2

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!