I'm not experto in geometry but I'm trying to do a software that handle triangles in various way. And I'm trying to learn geometry, of course : )
I have one fixed triangles $T1 = \hat{ABC}$ and a second triangle $T2 = \hat{DEF}$. I want to translate and rotate the second triangle so that the edge $AB$ overlaps the edge $DE$.
I think the right war is to handle the ray that goes from the middle point of BC and goes into the direction of the centroid of the second triangle. If I have the direction of that ray I can easily translate $T2$ and rotate it to the angle between BC and DE.
But I can't understand how do it even after a day of facing it. So I'm asking some helps. In particular when I'm doing it fine for one of the test case above in the other test case the ray is not facing in the right direction.
Here some numbers (I'm coding with Java but just to give numbers), and the respective visual result I'm expecting:
void initializeTriangle0() {
a = new Vec2D(-100, -100);
b = new Vec2D(100, -100);
c = new Vec2D(0, 100);
t1 = new Triangle2D(a,b,c);
edgeABC = new Line2D(b,c);
d = new Vec2D(-100, -200);
e = new Vec2D(100, -100);
f = new Vec2D(0, 100);
t2 = new Triangle2D(d,e,f);
edgeDEF = new Line2D(d,e);
}

void initializeTriangle1() {
a = new Vec2D(229.28932f, 300.0f);
b = new Vec2D(335.35535f, 406.27783f);
c = new Vec2D(335.35535f, 193.72217f);
t1 = new Triangle2D(a,b,c);
edgeABC = new Line2D(b,c);
d = new Vec2D(-35.355347f, -106.27784f);
e = new Vec2D(-35.35533f, 106.27784f);
f = new Vec2D(70.71068f, 5.0964204E-6f);
t2 = new Triangle2D(d,e,f);
edgeDEF = new Line2D(d,e);
}

void initializeTriangle2() {
a = new Vec2D(433.5996f, 233.33334f);
b = new Vec2D(233.2002f, 233.33334f);
c = new Vec2D(233.2002f, 433.33334f);
t1 = new Triangle2D(a,b,c);
edgeABC = new Line2D(b,c);
d = new Vec2D(-66.666664f, 66.666664f);
e = new Vec2D(133.33334f, 66.666664f);
f = new Vec2D(-66.666664f, -133.33334f);
t2 = new Triangle2D(d,e,f);
edgeDEF = new Line2D(d,e);
}

EDIT:
the last image is actually wrong because I'm expecting C===D && B===E
There are some inconsistencies in the question (e.g. talking about the edge $AB$, but using
(b,c)in the code), but I think that the general intention became clear.Admittedly, I did not fully understand your ray+centroid approach. However, here's a suggestion about how I would do it:
Given the edges that you want to align, compute the angle between these edges, and the centers of the edges. Then you can rotate the second triangle around the edge center about the angle that is required to make the edges parallel. Then, move the triangle, so that the edge center is at the same location as the center of the other edge.
You must be careful about the direction of the edges and the orientation of the triangles. Depending on wheter both triangles are oriented equally (both clockwise or both counterclockwise), and depending on whether you chose the edge $DE$ or $ED$, you'll have to add another rotation about $\pi$ - but it should be easy to figure this out for the particular case.
I just implemented this, using plain Java2D. So I'm using
Point2Dinstead of the unknownVec2Dclass etc - but the idea should become clear. The program allows dragging the corners of the right (pale blue) triangle, and it displays the aligned (dark blue) triangle.