Degenerate Polygons?

Started by
2 comments, last by Caroline_M 20 years, 6 months ago
I''m working through Lamothe''s Tricks book (2nd ed), and I''m on chapter 4 looking at basic GDI graphics. He wrote a little demo that creates polygons randomly by creating random points. He says "Notice, that because the points are random, the polygons are almost always degenerate due to overlapping geometry. Can you find a way to make sure that all the points exist within a convex hull?" I know nothing about graphics. I''m assuming that a degenerate polygon is one that kind of overlaps itself? I was thinking on this for a while and I really have no clue where to start with an algorithm like that but I''m guessing that it can''t be *too* hard by the way he just kind of threw it in there as an exercise. This kind of thing worries me a bit because it''s all well and good knowing how to use C++, Win32, DirectX etc to do things on the screen, but if I don''t know how to do basic things like this then I won''t get very far So along the same lines, if this book isn''t going to teach me how to apply what I''m learning to game development, then are there any books out there that focus more on the algorithms than the programming syntax? And if this is going to involve a load of math then I''ll probably just shelve it for a year or so until I have learnt more Thanks, Caroline M.
Caroline M
Advertisement
Hey,

From what I understand of degenerate polygons, they are basically a polygon with two or more points that are the same.

For example, if a triangle had two points, it would become a line, or if all three points are the same, it would be a point.

I hope this sheds some light, and that I have answered your question
-Boblin

Edit: hey, its 4 in the afternoon, I just woke up :-P

[edited by - Boblin on July 21, 2003 4:23:32 PM]
Yes, degenerate polygons are triangles with two or more points being the same. Graphics drivers / hardware recognize degerates and know not to try to render them.

I like pie.
[sub]My spoon is too big.[/sub]
I''ll give ya an example of how degenerate triangles are sometimes used, just so you can see why they''re very useful. Graphics cards are usually optimized to process triangle strips faster than any other drawing primitive (triangles, quads, polygons, triangle fans, etc.).

Basically, you define the first triangle by it''s three points, and then each successive triangle only needs one additional point defined as it uses the last two points from the previous triangle.

Example.
Triangle 1: (0, 0, 0) (0, 1, 0) (1, 0, 0)
You would then define a fourth point, say (1, 1, 0)
This would create a second triangle with points
(0, 1, 0) (1, 0, 0) (1, 1, 0)

How do degenerate triangles help? If you want to have two objects drawn using one triangle strip instead of having to have two separate ones. The less calls you make to the video card to draw, the better it usually is. So what you would do, is you would repeat the last point of the first object, and also repeat the first point of the second object.You then take these two separate objects, and stick them together.

This is basically how it works. A degenerate triangle is any triangle with two or more points that are exactly the same. This would result in either a line (2 points the same) or a point (3 points the same). If you''re telling the graphics card to draw triangles, it won''t draw any degenerate triangles. So the extra degenerate triangles that connect the two objects wouldn''t be drawn, so you''d only see the two objects you wanted. And you''ve used one triangle strip instead of two.

Of course, there is some overhead in skipping over degenerate triangles, and extra memory usage. You have to balance the pros and cons of using degenerate polygons.

This might seem kind of strange. I know it did the first time I was shown it. But it''s a pretty cool way to use the graphics card''s built in twists to your advantage.

A couple books I could recommend are:
Computer Graphics by Hearn and Bake
Mathematics for 3D Game Programming & Computer Graphics by Lengyel

This are math heavy, so if that''s a little daunting for you yet, they''re just something to keep in mind

-----------
Keith
-----------
-------------------------Keith-------------------------

This topic is closed to new replies.

Advertisement