How To Create Rotation matrix From Direction (unit vector)
My Matrix Is 3x3, Column Major, And Right Hand
I Know 'column1' is right, 'column2' is up and 'column3' is forward
But I Can`t Do This.
//3x3, Right Hand
struct Mat3x3
{
Vec3 column1;
Vec3 column2;
Vec3 column3;
void makeRotationDir(const Vec3& direction)
{
//:((
}
}
struct Mat3x3
{
Vec3 column1;
Vec3 column2;
Vec3 column3;
void makeRotationDir(const Vec3& direction, const Vec3& up = Vec3(0,1,0))
{
Vec3 xaxis = Vec3::Cross(up, direction);
xaxis.normalizeFast();
Vec3 yaxis = Vec3::Cross(direction, xaxis);
yaxis.normalizeFast();
column1.x = xaxis.x;
column1.y = yaxis.x;
column1.z = direction.x;
column2.x = xaxis.y;
column2.y = yaxis.y;
column2.z = direction.y;
column3.x = xaxis.z;
column3.y = yaxis.z;
column3.z = direction.z;
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments