How to build a tetrahedron matrix?

I would like to know how to build a matrix in the space of a tetrahedron. Is this possible?

I don’t believe that is correct. [Here][1] in the function ComputeBaryCentric3D they build a tetrahedron matrix. I just discovered this recently so I haven’t updated the question yet.

FVector4 FMath::ComputeBaryCentric3D(const FVector& Point, const FVector& A, const FVector& B, const FVector& C, const FVector& D)
{	
	//http://www.devmaster.net/wiki/Barycentric_coordinates
	//Pick A as our origin and
	//Setup three basis vectors AB, AC, AD
	const FVector B1 = (B-A);
	const FVector B2 = (C-A);
	const FVector B3 = (D-A);

	//check co-planarity of A,B,C,D
	check( fabsf(B1 | (B2 ^ B3)) > SMALL_NUMBER && "Coplanar points in FMath::ComputeBaryCentric3D()");

	//Transform Point into this new space
	const FVector V = (Point - A);

	//Create a matrix of linearly independent vectors
	const FMatrix SolvMat(B1, B2, B3, FVector::ZeroVector);

	//The point V can be expressed as Ax=v where x is the vector containing the weights {w1...wn}
	//Solve for x by multiplying both sides by AInv   (AInv * A)x = AInv * v ==> x = AInv * v
	const FMatrix InvSolvMat = SolvMat.Inverse();
	const FPlane BaryCoords = InvSolvMat.TransformVector(V);	 

	//Reorder the weights to be a, b, c, d
	return FVector4(1.0f - BaryCoords.X - BaryCoords.Y - BaryCoords.Z, BaryCoords.X, BaryCoords.Y, BaryCoords.Z);
}

This appears to create a non-orthagonal matrix to transform a point within the tetrahedron.
[1]: FMath::ComputeBaryCentric3D | Unreal Engine Documentation

This drawing shows what I’m trying to accomplish. I’m pretty sure I can do this using Barycentric Coordinates, and They can be precomputed too so that is nice. But, I wanted to learn how to do this using a matrices. I believe one advantage would be that I could use the matrix transform to not only adjust the vertex location, but also the vertex normals. I’m really looking for information on how this process would work. I’m close to have a scenario to test with…

at first, i thought you were trying to pack regular tetrahedrons into a 3D tessellating structure… now im not sure what you are trying to do.

The drawing above shows on the left a tetrahedron matrix that is build using the vectors b-a, c-a, z-a (z is the top of the tetrahedron). Then I want to move the matrix into the space of the right matrix, which is almost the same but has the b vert raised upwards. Now if you were to imagine point “P” being in the position it is in the left matrix, when it is transformed into the matrix b on the right the point “P” would be raised along with the vertex B.

i don’t know how to do it with matricies, but if i understand the problem correctly, you could just add up all the distances from the target point to each vertex, then divide each distance by that total, to get normalized weights for each vert.

then you take the change in position for each vertex, from the old tetrahedron to the new tetrahedron, and multiply each vector by its respective weight, total the resulting vectors, then add it to the target points previous location. that should skin the point to the deformed mesh.

Yeah that way I have figured out. The ComputeBaryCentric3D will actually return a FVector4, each channel is the respective weight for the position to vertex. I was wanting to see how the matrices way would work. The problem with the above is that then I have to calculate the surface normal as well. Point “P” is one of many that will be getting deformed into the correct position within the second matrix. So I’ll need to update the normals as well. While coming through the code of the computeBaryCentric I see they build the above matrix so this has me hopefuly. I did some digging and I came across this which says " If you want to transform a surface normal (or plane) and correctly account for non-uniform scaling you should use TransformByUsingAdjointT.". I looked and could not find a function perfectly matching that name but there is one called FMatrix::TransposeAdjoint. I believe I’m close with the matrices, but I have a couple things I need to understand. Precalculating the Barycentric coords is nice, but then you have to apply those vert weights, and still you have to manually fix the surface normal.