I have a Mesh already rotating (Rx, Ry, Rz) and a set maximum force (F). I want to find out the Torqu to call pass to AddTorqueInDegrees.
So, straining hard to remember Quaternions, I have:

FRotator CurrentRotations=GetCurrentRotationVelocity(); // Caclulated by subtracting the previous GetComponentRotation against the current
FVector TargetVector(TargetRollSetting, TargetPitchSetting, TargetYawSetting);// There are from input, [-1, 1]
FQuat TargetQuat = FQuat::MakeFromEuler(TargetVector);
FQuat Applied = TargetQuat - CurrentRotation;
FVector AppliedForce = Applied.Euler().GetSafeNormal() * Force;
MeshComponent->AddTorqueInDegrees(AppliedForce)

But Applied.Euler() is always [0,0,0]

I’m sure I’m doing something wrong with math or maybe making it more complicated. Can anyone point me in the right direction?

Hi @bambitlaw. I will try to help, but no guarantees First thing that jumps out to me if you copy pasted your code is what appears to be a typo. Line 1 and line 4 have CurrentRotations being defined, and then singular CurrentRotation being used. Would be surprised if that actually compiles u less CurrentRotation is a valid parameter and being set elsewhere.

Also, I’ve had to work with rotators and quaternions in conjunction recently. It’s important to remember that some data oohs always lost when converting from quaternions to rotators. Otherwise, nobody would use a four element, difficult to visualize quaternion when we could use a simple Euler rotation instead.

First, I wouldn’t be surprised if somewhere in the codebase there is a function accepting a rotator to apply a rotational force. On the flip side, I also wouldn’t be surprised if there isn’t. Look for that first.

Second, try to just use rotators. You probably already have, and that’s what brought you to attempting a hybrid quaternion/rotation solution. In my personal experience, even if you get it close using this method, you will start seeing strange, inexplicable behavior. Likely due to the loss of data during the conversions.

Lastly, as noted in this answer quats , I’m not sure subtraction is what you want to aggregate a quaternion rotation, unless the unreal math library assumes what the developer wants to do and handles it.

“…you can accumulate rotations by multiplying unit quaterions…”

Godspeed developer, hope this helps, and let me know if you figure it out.

Thanks for the advice, I’ll look some more for the torque with a FRotator but not sure that’s going to solve my problems, or not. If I have an object rotating at FRotator Original(170,10,30) and I actually want it to rotate at FRotator Target(-170,-5,40), what would be the math on the rotators? Will simple subtraction ( FRotator Applied = Original - Target ) yield FRotator(-20,-15,10)? I could do that calculation myself, but Quats also avoid gimbal lock…however, that may be what I need to do…do the calculations manually on the rotator and then get the quat…

Also, the typos were not from copy paste, just retyping the code manually =)