Math question, center of triangle that is part of a square

basically

if i want to have a square whose bottom left point is 0,0 and top right is 1,1
the center of that square is .5,.5

but what if i want to have a triangle which is half that square exactly.

so its bottom left is still 0,0
its other points are 1,0 & 0,1

where exactly is that center of that triangle (it appears to PERHAPS be 1/3rd)
is it indeed
.333_,.333_
?

It depends on what kind of center you want, there are lots of different ones… :wink:

One of the easiest ones (and probably the one you’re after) is the Centroid. You get it by taking the arithmetic mean of all points. So simply add the 3 points together and divide by 3. So if A, B, C are vectors of the 3 corners, you just do:

    center = (A+B+C) / 3;

In your case (0,0) + (1,0) + (0,1) == (1,1)

(1,1) / 3 => (0.333,0.333)

However this works for any triangle.