MakeRotationFromAxes gives me wrong results

Hello everyone,
I’m trying to calculate a new reference system based on a normal vector. This appears to be more complicated than I thought and I think I am stuck because of a potential bug with MakeRotationFromAxes or FMatrix (but I could be using it wrong).

In short if I try to get this rotator:

		rotation = UKismetMathLibrary::MakeRotationFromAxes(-FVector::ForwardVector, -FVector::RightVector, -FVector::UpVector);

I expect it to be upside down, something like this:

 {Pitch=0.000000000 Yaw=180.000000 Roll=180.000000000 }

254529-capture.png

but I get this:

{Pitch=0.000000000 Yaw=180.000000 Roll=0.000000000 }

254530-capture2.png

that is simply facing back but not upside down.
Am I missing something basic? The problem is easily reproduceable (in the pictures I am using the base cone in unreal).

Thank you in advance for your help,

Hello Eibis,

Can you please provide your full class(.cpp) and header file (.h) for this particular class?

Hello Nicholas, thank you very much for your answer!

Sure, here is my test:
MyStaticMeshActor.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Engine/StaticMeshActor.h"
#include "MyStaticMeshActor.generated.h"

/**
 * 
 */
UCLASS()
class GEOMETRYRUN_API AMyStaticMeshActor : public AStaticMeshActor
{
	GENERATED_BODY()

public:

	AMyStaticMeshActor();
	
protected:
	virtual void BeginPlay() override;
	
};

MyStaticMeshActor.cpp
// Fill out your copyright notice in the Description page of Project Settings.

#include "MyStaticMeshActor.h"
#include "Runtime/Engine/Classes/Components/StaticMeshComponent.h"
#include "Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h"
#include "Runtime/Engine/Classes/Kismet/KismetMathLibrary.h"

AMyStaticMeshActor::AMyStaticMeshActor() : AStaticMeshActor()
{
	static ConstructorHelpers::FObjectFinder<UStaticMesh> Mesh(TEXT("StaticMesh'/Game/StarterContent/Shapes/Shape_Cone.Shape_Cone'"));
	GetStaticMeshComponent()->SetStaticMesh(Mesh.Object);
	SetMobility(EComponentMobility::Movable);
}

void AMyStaticMeshActor::BeginPlay()
{
	Super::BeginPlay();

	FRotator rotation = UKismetMathLibrary::MakeRotationFromAxes(-FVector::ForwardVector, -FVector::RightVector, -FVector::UpVector);
	SetActorRotation(rotation);
}

I get the same result of my second screenshot, with these values as rotation:
{Pitch=0.000000000 Yaw=180.000000 Roll=0.000000000 }

Hey Eibis,

The issue you’re experiencing may be a physics error. when you call MakeRotationFromAxes the negative operand values you are providing are “cancelling each other out”.

Instead, you only need to negate the x or y value to get your desired rotation.

For Example:

Here we will make the ForwardVector(X) negative.

FRotator rotation = UKismetMathLibrary::MakeRotationFromAxes(-FVector::ForwardVector, FVector::RightVector, FVector::UpVector);

This will yield the following:

254615-negativefowardvector.png

Here we make the Right Vector(Y) negative

FRotator rotation = UKismetMathLibrary::MakeRotationFromAxes(FVector::ForwardVector, -FVector::RightVector, FVector::UpVector);

This will yield the following:

254616-negativerightvector.png

Thank you for your answer, I understand the problem now ^^