# FQuat::FindBetween gives weird results

Hello.

I am using on a gravity system and for camera to work, I need to determine the rotation amount between forward and right vectors so I can add this amount to the character. It is working well, except for the Y axis gravity. Just to test, I assumed I am looking at X and thus -Z is my right vector. Just not to get affected by the random rotation amounts, I can this:

FQuat::FindBetween(FVector(1,0,0),FVector(0,0,-1));

and the result is -90 pitch, rest zero, as it should be.

However, when I fetch the same vector values from my calculations and use FindBetween with them, even though values are extremely similar, I get some crazy amounts.

This is the code block I am using:

``````

FRotator DestinationRotation = FQuat::FindBetween(GetActorUpVector(), GravityDirection*-1).Rotator().Add(GetActorRotation().Pitch, GetActorRotation().Yaw, GetActorRotation().Roll);

FVector Test1(0.9999, -0.000001, -0.0003);
FVector Test2(-0.03, 0.0009, -0.99);

FQuat Findbetween = FQuat::FindBetween(Test1, Test2);
FRotator Test(Findbetween);
PrintRotator(Test, "Test", 7); // Yields -88, 178, -178

PrintRotator(DestinationRotation, "DestinationRotation", 5);
FVector TargetForwardVector(UKismetMathLibrary::GetForwardVector(DestinationRotation));
FVector TargetRightVector(UKismetMathLibrary::GetRightVector(DestinationRotation));
PrintVector(TargetForwardVector, "DestinationForward", 3);
PrintVector(TargetRightVector, "DestinationRight", 4);

FRotator RotationOfTurn(FQuat::FindBetween(TargetForwardVector, TargetRightVector));
PrintRotator(RotationOfTurn, "RotationOfTurn", 6);

``````

Printer code in case there might be a mistake:

``````

void ACryOnCharacter::PrintRotator(const FRotator &Rotator, FString Name, int32 Permanumber)
{
GEngine->AddOnScreenDebugMessage(Permanumber, 50.f, FColor::Yellow, Name + "Pitch: " + FString::SanitizeFloat(Rotator.Pitch) + " Yaw: " + FString::SanitizeFloat(Rotator.Yaw) + " Roll: " + FString::SanitizeFloat(Rotator.Roll));
}

``````

Print log: http://imgur.com/a/aWUDP

The approach I am following is:
I linetrace to a wall, get the normal and set the gravity to the - of it, works alright. I use FindBetween with actor up vector and the normal to determine the angle change of my character and apply it during tick, which also works alright. But to determine my turning rotation, I find the characters future rotation (From the previous sentence) get Up and Right vectors from it and use FindBetween again to find the 90 degree angle between the two vectors. The funny thing is, it only occurs when Y axis is the gravitation axis and FindBetween should never yield any angle greater than 90 degrees when used on up and forward vectors.