How do I build a matrix to translate one set of points to another?

Posted by dotminic on Game Development See other posts from Game Development or by dotminic
Published on 2011-11-24T19:58:32Z Indexed on 2011/11/25 2:20 UTC
Read the original article Hit count: 170

Filed under:
|
|

I've got 3 points in space that define a triangle. I've also got a vertex buffer made up of three vertices, that also represent a triangle that I will refer to as a "model".

How can I can I find the matrix M that will transform vertex in my buffer to those 3 points in space ?

For example, let's say my three points A, B, C are at locations:

A.x = 10, A.y = 16, A.z = 8
B.x = 12, B.y = 11, B.z = 1
C.x = 19, C.y = 12, C.z = 3

given these coordinates how can I build a matrix that will translate and rotate my model such that both triangles have the exact same world space ? That is, I want the first vertex in my triangle model to have the same coordinates as A, the second to have the same coordinates as B, and same goes for C.

nb: I'm using instanced rendering so I can't just give each vertex the same position as my 3 points. I have a set of three points defining a triangle, and only three vertices in my vertex buffer.

© Game Development or respective owner

Related posts about c++

Related posts about math