Announcement

Collapse
No announcement yet.

Calculating FRotationMatrix that rotates Vector A to align with Vector B in Ue4.

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

    Calculating FRotationMatrix that rotates Vector A to align with Vector B in Ue4.

    Hey!

    I am trying to find the FRotationMatrix that will rotate one vector to align with another. I then want to apply that matrix to another completely different vector, so that both are effectively rotated as a if they were glued together. Basically, this article describes very well the math of it: http://math.stackexchange.com/questi...vector-b-in-3d . However, I can not help but think that FRotationMatrix should give me an easier way than to cruely calculate this by hand.

    Basically I need some help to understand the features of Unreals Rotators, Quats and RotationMatrix in order to understand what my options are here..

    Any help is greatly appreciated : )

    #2
    Rotator - Utility class for getting/setting rotational information. Can be used to create a Quat.
    Quat - Quaternion rotation.
    RotationMatrix - A 3x3 rotational matrix (under the hood its actually a 4x4 matrix just without a translation).

    A Rotator or a Quat can be used to create a RotationalMatrix which is the actual end product used to create the final transform of an actor.

    Rotators are actually incredibly easy to use and you can probably use that to figure out the relative rotation you need to make two entities align. You should be able to simply do TargetRotator - CurrentRotator to get a delta rotator that you could then apply to both entities.

    Comment


      #3
      Originally posted by AdeptStrain View Post
      Rotators are actually incredibly easy to use and you can probably use that to figure out the relative rotation you need to make two entities align. You should be able to simply do TargetRotator - CurrentRotator to get a delta rotator that you could then apply to both entities.
      Ah this is great. So if I had Vector A and B, I could get A.Rotation() - B.Rotation() and this is the rotation from B to A I assume?

      Comment


        #4
        Yup, then just apply it via AddActorWorldRotation/AddActorLocalRotation depending on what transform space you're working in.

        Comment


          #5
          Originally posted by juggle View Post
          Ah this is great. So if I had Vector A and B, I could get A.Rotation() - B.Rotation() and this is the rotation from B to A I assume?
          This is exactly what I'm attempting to do, however, using blueprints - does anyone know which nodes can do this?

          Comment

          Working...
          X