(i'm on OPENGL)
i have a mesh O (object) and a mesh T (terrain). i know a single triangle in T and i want to orient O to be aligned to that triangle (torate O to align to T in that point).
i have only the normal in the triangle. how can i achive the roation matrix?
i have thought this algorithm:
// pseudocode
float[] normal2rotation(Vector3D normal) {
angleX = Vector3D.angleBetween(normal, Vecto3D.Axis3D.X);
angleY = Vector3D.angleBetween(normal, Vecto3D.Axis3D.Y);
angleZ = Vector3D.angleBetween(normal, Vecto3D.Axis3D.Z);
float[] result = {angleX, angleY, angleZ};
return result
}
but it does not give me the desired result.