Direction Vector To Rotation Matrix

UfnCod3r

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)
    {
        //:((
    }
}
UfnCod3r
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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android Rotation Vector and Rotation Matrix

From Dev

LibGDX Matrix4 3d rotation problems given direction vector3

From Dev

Given 3D rotation matrix and 3D direction vector finding angular difference

From Dev

Haskell Gloss : direction vector to angle for rotation

From Dev

3D rotation using direction vector

From Dev

Apply rotation matrix to vector + plot it

From Dev

OpenGL object rotations using a direction vector and transformation matrix

From Dev

Adjusting a Vector3 after a Matrix rotation has occured

From Dev

Find rotation matrix of one vector to another using R

From Dev

About CGAffineTransformMakeRotation rotation direction?

From Dev

unity rotation difference and direction

From Dev

Bullet firing in direction of rotation

From Dev

Implementing current cardinal direction method with TYPE_ROTATION_VECTOR while standing still?

From Dev

Tween rotation in Easeljs: Control direction of rotation

From Dev

Is the rotation matrix unique for a given rotation?

From Dev

Move object in the direction of it's rotation

From Dev

gluLookAt + direction vector

From Dev

OpenGL camera/direction vector

From Dev

Quaternion To Direction Vector

From Dev

OpenGL camera/direction vector

From Dev

Point arrow in vector direction

From Dev

Absolute rotation using Matrix?

From Dev

Rotation matrix to euler angles

From Java

Saving rotation Matrix in OpenGL

From Dev

How to undo a rotation on a matrix

From Dev

Matrix manipulation (rotation/rolling)

From Dev

Rotation matrix to quaternion equivalence

From Dev

Essential Matrix: Pure Rotation

From Dev

Rotation matrix multiplication error