Skip to main content
GameDev.net gamedev.net
🔒 Locked

Triangle orientation

Started by FERNANDO-BRASIL Sep 18, 2005 at 9:12 AM 8 replies 9.1k views
Original Post
FERNANDO-BRASIL
FERNANDO-BRASIL
Hi there. What topic of Math cover this technique? I have saw on the Internet, that people gets triangle orientation by calculating the next determinant: | Bx-Ax By-Ay | | Cx-Ax Cy-Ay | in other words, (Bx-Ax)*(Cy-Ay) - (Cx-Ax)*(By-Ay) Where A and B and C are points A(x, y) and B(x, y) and C(x, y). If determinant <= 0, the points A, B and C are disposed in counter-clockwise order. In what part of math we can saw this explanation? Is this technique (of calculating triangle orientation with determinants) math related or engineering related? Thanks. [Edited by - FERNANDO-BRASIL on September 18, 2005 9:29:06 AM]
braindamage
braindamage
I believe that determinant is a way of calculating the cross product (AxB) of two vectors.
jjd
jjd
Quote:
Original post by braindamage
I believe that determinant is a way of calculating the cross product (AxB) of two vectors.


This is not entirely correct. It is true that the calculations used by both in 2D are similar, but they are different in higher dimensions and means different things.

I've seen the determinant used in high-dimensional problems to determine orientation along a 1D curve through nD space. However, I think it is easiest (conceptually) to think of the technique you are using in terms of the cross product.

The cross product is called non-commutative, which means that AxB != BxA. So the order in which you "multiply" the vectors together is important. For the cross-product you have the relation that AxB = -BxA. In other words, if you change the order of A and B, you chance the sign of the finally outcome. This is why the method you are using works. Try it! [smile]


-Josh
FERNANDO-BRASIL
FERNANDO-BRASIL
Hey guys. I'll change my question.

The technique I first presented (of calculating triangle orientation with determinants), where do I find it?

In math books, in engineering books, or in math-game books?

Thank again.
FERNANDO-BRASIL
FERNANDO-BRASIL
Quote:
Original post by Anonymous Poster
It's too late for you to find it in a book. You already found it on the internet.

It can probably be found in computer graphics books. Since some game programming books cover some computer graphics theory, it may be found there too. But I don't know what books in particular would mention the technique. It's really a fancy way of writting a cross product for two dimensional vectors.


Thanks.

I was asking that because a lot of sites have techniques made by others and they don't put the author's name there.

I've been trying to construct an algorithm that detects triangle orientation, and as I failed on the objective, I searched it on the internet.

I found a technique with determinants (or better, coincidentally is a determinant or a cross product) and one related to polygon's area. I have some books of math at home, but didn't find one that has the determinant's one exposed.

So, I posted a message here to see if any of you known that.

I imagine that the technique would be seen on books with Triangle study theory, but I don't know a good one... My math knowledge is very poor!

Thank you.
jjd
jjd
Well, a good way to find what you are after is to google using terms like "linear algebra" "graphics" "game programming" etc. You should find some helpful theory that way.


-Josh
FERNANDO-BRASIL
FERNANDO-BRASIL
Quote:
Original post by Anonymous Poster
Um, I think the technique that uses the signed area ia actually also the same as the determinant and the cross product technique for finding triangle orientation. They all end up with using the sign of (Bx-Ax)*(Cy-Ay) - (Cx-Ax)*(By-Ay) to determine orientation.

The cross product of two vectors is actually equivalent to the signed area of a parallelogram with those two vectors as adjacent sides. The area of a triangle is half that of a parallelogram.

They are all different ways of geometrically interpretting the same result.


Yes. You're right!

Thanks for your answers guys!
You're always glad with newbies.

Fernando.
Dmytry
Dmytry
This technique is example of use of vectors (and some linear algebra). You can learn more about vectors in math books discussing this topic, math for games books, or math for engineering books.

speaking of "determinant" versus "2D cross product":
Cross product is defined only in 3 dimensions; in other dimensions you have various "analogs" like so-called "2D cross product" that is usually defined as determinant. But there is other analogs, and determinant seems to be somewhat less ambiguous.

Another interesting fact is that determinant always gives signed area or volume or "hypervolume" of corresponding parallelogram (or parallelepiped or higher dimensional analog).

[Edited by - Dmytry on September 18, 2005 12:54:57 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.