#Put perfect triangle in a middle of rectangular canvas

6 messages · Page 1 of 1 (latest)

turbid owl
#

I know width and height of canvas. Canvas is rectangle.
I need to know what size of side triangle should have, and positions of vertices.
Its an easy question, I'm just bad at math/geometry.
I only understood that, if i had squarish canvas, i could just devide width and height by 3, and middle parts would become size of side of triangle. But its a rectangle, and i want a perfect triangle, if i'll try to apply it here, it would be stretched, so i need additional offset, and i have no idea how to calculate one. :V

its not for school or any other place, its just for a simple script that i wanna try to write, that will work with images, and i need to put perfect triangle there, in the center.

topaz glacierBOT
placid kernel
#

so center of triangle is at (x/2, y/2) where x, y canvas dimensions

turbid owl
olive star
#

Note NDC is in the range [-1,1] for both axes