# MakeRotationFromAxes gives me wrong results

**URL:** <https://forums.unrealengine.com/t/makerotationfromaxes-gives-me-wrong-results/434343>\
**Category:** C++\
**Tags:** get-actor-right-vect, unreal-engine, vector, geometry, UE4, question, CPP\
**Created:** [September 23, 2018, 3:37pm UTC](https://forums.unrealengine.com/t/makerotationfromaxes-gives-me-wrong-results/434343 "2018-09-23T15:37:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_10c65d791](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_10c65d791](https://forums.unrealengine.com/u/anonymous_user_10c65d791)\
**Post date:** [September 23, 2018, 3:37pm UTC](https://forums.unrealengine.com/t/makerotationfromaxes-gives-me-wrong-results/434343/1 "2018-09-23T15:37:05Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/2/3/8235b937ec25b9e557854fc624910d119afd348f.png)

but I get this:

```
{Pitch=0.000000000 Yaw=180.000000 Roll=0.000000000 }

```

![254530-capture2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/4/4/b44d54b0fe07455d0709d6e903ffbd78d36e63ec.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,

---

<div class="post-metadata">

**Author:** ![NicholasMont](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NicholasMont](https://forums.unrealengine.com/u/NicholasMont)\
**Post date:** [September 24, 2018, 5:11pm UTC](https://forums.unrealengine.com/t/makerotationfromaxes-gives-me-wrong-results/434343/2 "2018-09-24T17:11:21Z")

</div>

Hello Eibis,

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_10c65d791](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_10c65d791](https://forums.unrealengine.com/u/anonymous_user_10c65d791)\
**Post date:** [September 24, 2018, 5:56pm UTC](https://forums.unrealengine.com/t/makerotationfromaxes-gives-me-wrong-results/434343/3 "2018-09-24T17:56:35Z")

</div>

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 }

---

<div class="post-metadata">

**Author:** ![NicholasMont](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NicholasMont](https://forums.unrealengine.com/u/NicholasMont)\
**Post date:** [September 24, 2018, 8:08pm UTC](https://forums.unrealengine.com/t/makerotationfromaxes-gives-me-wrong-results/434343/4 "2018-09-24T20:08:09Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/a/a/1aa086c44a1621f6f3cdde01b2e0fff366489b45.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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/7/9/e79254f861c4b388e8f5260bbbbc595d3623059a.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_10c65d791](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_10c65d791](https://forums.unrealengine.com/u/anonymous_user_10c65d791)\
**Post date:** [September 25, 2018, 8:35am UTC](https://forums.unrealengine.com/t/makerotationfromaxes-gives-me-wrong-results/434343/5 "2018-09-25T08:35:07Z")

</div>

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