When I want to implement axis aligned 2d rectangles I always go with {x, y, w, h}
, because that is the natural approach to it. With 3d axis aligned rectangles you need {x, y, z, w, h, d(depth)}
. For a 2d triangle I need {x1, y1, x2, y2, x3, y3}
. But what do I need for axis aligned right triangles. How would you store them?
I can imagine going with the same data as a rectangle and then a number 0 to 3 indicating which point is opposite to the hypotenuse. I can also imagine going with {x, y, w, h}
, where w
and h
is allowed to be negative (opposite to the normal rects).
Which is the common approach to implementing right triangles?
EDIT:
Well I finally decided to go with {x, y, w, h, r}
, where w, h >= 0 and r is the radians.
So at first I can concentrate r = {0, pi/2, pi, 3pi/2}
and if I wanna go crazy later on, I can do just that without breaking my interface.
How would you store [a right triangle]?
-- The same way you would store any other triangle. Why would you specialize the storage of right triangles?