logoalt Hacker News

airbreather • today at 12:00 PM • 4 replies • view on HN

Why the obsession with triangles?

If you just want areas, or to know if a point is inside or outside the shape there is a better way.

Given a simple closed curve, points (ax, ay) (bx, by) (cx, cy) (dx, dy) as a trivial example.

Line them up a,b,c,d,a vertically and take the "determinant" as we were taught.

Axby - aybx + bxcy - bycx etc etc.

Divide the result by -2 and you have the are, positive is clockwise, negative is anticlockwise.

Put an anticlockwise shape inside a clockwise shape and you have a donut.

There is more, have to go to dinner.


Replies

jcattle • today at 12:02 PM

Obsession with triangles so the GPU can show millions of polygons on a webmap.

jplusequalt • today at 3:44 PM

Hardware/software rasterizers are already doing the "inside or outside" check millions/billions of times a second using the same determinant trick.

adrian_b • today at 12:33 PM

The obsession with triangles comes from Microsoft, who around 1995 chose to support only triangles in DirectX.

As a consequence of that, the GPU vendors designed then GPUs supporting only triangles in hardware, abandoning earlier attempts to also support other figures.

That has been inherited until today, so any program that wants to use not only the general-purpose computing features of a GPU, but also the dedicated graphics hardware from it, must convert any other kinds of graphics primitives into triangles, before rendering on the GPU.

Sharlin • today at 12:13 PM

There’s this thing called rendering, pretty important for maps.

➕ show 1 reply