Rotator to Vector ?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Well, vector to rotator casting uses trigonometric functions to calculate the rotator's Yaw component from the vector's X and Y components, while the rotator's Pitch component might be calculated from the normalized vector's Z component somehow.
I didn't figure out Pitch yet, but Yaw can be calculated through something like this:
Code:
  if ( V.X == 0 && V.Y > 0 )
    R.Yaw = 16383;
  else if ( V.X == 0 && V.Y > 0 )
    R.Yaw = 49151;
  else if ( V.X != 0 ) {
    F = ACos(V.X / VSize(V * vect(1,1,0))) * 32768 / Pi;
    if ( V.Y > 0 )
      R.Yaw = F;
    else
      R.Yaw = 65536 - F;
  }
Here "V * vect(1,1,0)" is a component multiplication, i.e. for this special case the vector is projected onto the X-Y plane and that projected vector's length is used.

Some standard vector to rotator conversions are:
vect(1,0,0) -> rot(0,0,0)
vect(0,1,0) -> rot(0,16383,0)
vect(0,0,1) -> rot(16383,0,0)
 
Last edited:

BigSquid

Programmer, Epic Games
Oct 21, 2002
6
0
0
Raleigh, NC
Visit site
It is as the wise Wormbo said! Rotator -> Vector just transforms the x-axis by that rotator and gives it to you. So a rotator of (0,0,0) gives you a vector of (1,0,0) etc. Obviously this throws away the roll of the rotator so if you go rotator -> vector -> rotator it wont necessarily be the same.

Vector -> Rotator just figures out a pitch and yaw to point the x axis in the direction you give. I believe the roll will always be zero after this.

If I had the C++ code handy I'd post exactly how it works, but I'm afraid I don't...