Heading/Pitch/Roll Flipping Issue

I have an object that is being rotated in engine. I’m sending object’s location (x,y,z) and rotations (heading, pitch, roll) to a different software.

When you manually enter in position and rotations values, in Unreal Engine 4, information is correctly transferred to other software.

If you use rotation tool to alter object, information passed suffers odd conversions. When physics are applied to object position values are correct, but rotations show odd flipping back and forth.

How can we have values transferred in same manner as when you enter in values?

Thanks for help!

Hey tthorpe,

I’d like to make sure I understand you correctly.

  • Is this occurring with a static mesh included in engine, or is it one you imported? Or is a BSP?
  • Does odd flipping you describe occur in editor or only in external program you’re using?
  • Which external program are you referring to?

Thanks!

#Solution

FRotator has odd behaviors regarding this flipping you are seeing, I encountered it earlier today, and for past year or so. Going from 181 to -179 is actually a correct behavior, but you are indeed noticing that there’s some places where rotator goes from -180 to 180 and other places where it goes 0 to 360

sooooo

I just today made a node to standardize this FRotator flipping issue

You should always standardize FRotator before sending it to your software and then you will be done with this issue.

Then your results will always be consistent! Standardized!

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//		Solution to All Those Rotator Issues
//			Remap it to always be in -180 to 180!
//  -
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
static FORCEINLINE FRotator StandardizeRotator(const FRotator& Rotator)
{
	return FRotator(
		(Rotator.Pitch > 180) ? Rotator.Pitch - 360 : Rotator.Pitch,
		(Rotator.Yaw > 180) ? Rotator.Yaw - 360 : Rotator.Yaw,
		(Rotator.Roll > 180) ? Rotator.Roll - 360 : Rotator.Roll
	);
}

#Summary

If you standardize all your FRotators to be in range [-180,180] for pitch yaw and roll, then you can do reliable math calculations based on your FRotators and you wont get odd flipping behaviors

:slight_smile:

Thanks for your help .

object was imported from Maya as a .fbx file. flipping occurs only in external software, which is an internal program I am working on.

main concern I have is that it appears that rotation is being passed differently when using Unreal for editing postions and rotations, when compared to simulating game world and altering them with physics. Is it possible that values being passed while simulating are using Quaternions?

moment that I enter in 181 for X rotation, it automatically changes it to -179.999… Do you know what is causing this? This could be a cause of issue, but I would like to confirm.

I have included an image as well.!

Thanks for your help .

I believe current issue I’m having is caused by order of rotation. other software is performing rotations by:

Yaw Pitch Roll

And apparently Unreal is performing rotations by:

Pitch Yaw Roll

Is there a built in function that can alter order of rotation?

Thanks again for help.

,

I have been altering rotation values, and I am unsure of what it is doing. By altering Z-axis value to 30 Degrees causes model’s rotation to be altered, but not in Z-axis. It alters X-axis to be negative 30 Degrees.

I am just feeling lost on this one. Any thoughts or suggestions?