Announcement

Collapse
No announcement yet.

Understanding FRotationMatrix::MakeFromX

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Understanding FRotationMatrix::MakeFromX

    I needed to rotate an object to the player and I looked at the blueprint code from the Blueprint office because I remembered that they had those info tables. It uses MakeFromX to rotate an object always to the player.

    https://github.com/EpicGames/UnrealE...lMath.cpp#L339

    I am not sure if I understand the math behind it. I give it a vector that goes from the object to the player and it calculates a rotation matrix that rotates the object to the player.

    But all it does is really creating two orthonormal vectors from the object-to-player vector and puts it in a matrix. How can that be the correct rotation? And it also seems to rotate around the Z and Y axis.

    I hope someone can enlighten me.

    #2
    Okay I think I understand the math behind it. If you write the vectors in the rows it is the same as the dot product for every vector.

    Comment


      #3
      I am not 100% sure but I think it creates a matrix that describes an orthonormal basis in 3d-space where the provided vector is the X-Axis.

      Comment


        #4
        You might also want to look at functions like FRotationMatrix::MakeFromXZ. That will point X (forward) in the direction you want, and Z (up) will be changed as much as needed to be orthogonal to X. That way you can specify which direction to try and keep 'upright' in your rotation.
        Lead Programmer - UE4 Animation/Physics/Audio Team - Epic Games
        Twitter: @EpicJamesG

        Comment


          #5
          thats very good to know. thx James

          Comment

          Working...
          X