# Rotate a mesh around it's center using quaternion

**URL:** <https://forums.unrealengine.com/t/rotate-a-mesh-around-its-center-using-quaternion/444575>\
**Category:** Community & Industry Discussion\
**Tags:** math, logic, unreal-engine, question\
**Created:** [March 4, 2019, 1:34pm UTC](https://forums.unrealengine.com/t/rotate-a-mesh-around-its-center-using-quaternion/444575 "2019-03-04T13:34:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![IronSuit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IronSuit](https://forums.unrealengine.com/u/IronSuit)\
**Post date:** [March 4, 2019, 1:34pm UTC](https://forums.unrealengine.com/t/rotate-a-mesh-around-its-center-using-quaternion/444575/1 "2019-03-04T13:34:12Z")

</div>

I would like your help if possible as i don’t know a lot of quaternion me myself.

so i have a cylinder and i want to rotate around the up vector as its axis of rotation when i press up or down arrows or swipe on touch.and i want to rotate it around the right vector when i swipe left or right, or pressing left and right keys on keyboard.

My current setup is this

[![Imgur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/a/7faee67cf32a75e3ac28e0438445dcf589b87454.png "imgur.com") ](https://imgur.com/llYnc9P)

and this is the cylinder i want to rotate.

[![Imgur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/e/b/aeb1e6615f2b9c3e9fbb3422a7d43bdb2e82a3ff.png "imgur.com") ](https://imgur.com/Od0Slq1)

So basically, i want when i press the up or down keys (or in case of mobile to swipe up or down) is to rotate around the green arrow and when pressing left and right i want to rotate around the red arrow.

I use quaternion bleuprint plugin found here [Blueprint Quaternion Library in Code Plugins - UE Marketplace](https://www.unrealengine.com/marketplace/blueprint-quaternion-library)

you can check the photos of the plugin for all of the available nodes.

i would appreciate any help.

Many Thanks

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [March 4, 2019, 3:09pm UTC](https://forums.unrealengine.com/t/rotate-a-mesh-around-its-center-using-quaternion/444575/2 "2019-03-04T15:09:58Z")

</div>

This tutorial will show you how to use quaternions for rotations.

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/c/e/fce1580f5d1db57d50096ad9685a62afad745c7b.jpeg "#gimbal #6DoF #quaternion Unreal Engine 4 Tutorial: 6DoF Fixing Gimbal Lock") ](https://www.youtube.com/watch?v=KqbqZ3IY1II)

Haven’t bought that quaternion plugin so I can’t say for sure what to use from there but the nodes should largely be similar. Looking up in the FQuat API there is a C++ function “Make From Euler” this is probably what you will want to use as a blueprint node if the plugin has make that accessible to you.

> **[FQuat::MakeFromEuler](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Core/Math/FQuat/MakeFromEuler/)**
>
> Convert a vector of floating-point Euler angles (in degrees) into a Quaternion.

---

<div class="post-metadata">

**Author:** ![IronSuit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IronSuit](https://forums.unrealengine.com/u/IronSuit)\
**Post date:** [March 4, 2019, 8:43pm UTC](https://forums.unrealengine.com/t/rotate-a-mesh-around-its-center-using-quaternion/444575/3 "2019-03-04T20:43:10Z")

</div>

Please check the gif so you know what’s my problem

> <https://gfycat.com/slimyperfectbluebreastedkookaburra>

my current blueprint setup is

 ![270277-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/e/3fe50460e38b0598527ffb831a19f11436611fdb.png)

i’m able to rotate around the up vector as my axis of rotation for left and right panning.

but for up and down panning weird issue happens.  
i think because of the Euler gimbals lock.

---

<div class="post-metadata">

**Author:** ![IronSuit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IronSuit](https://forums.unrealengine.com/u/IronSuit)\
**Post date:** [March 5, 2019, 8:45pm UTC](https://forums.unrealengine.com/t/rotate-a-mesh-around-its-center-using-quaternion/444575/4 "2019-03-05T20:45:55Z")

</div>

i was able to solve the problems using those nodes.

 ![270405-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/4/5/545bb659c4a7f503bf4e1a71da0d1e3a5d9a4c24.png)

 ![270404-capture1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/9/a/59a3b3d625046c2124bc2842ec0923f0e50e7566.png)

This was used with quaternion plugin to find the quat at the y axis and to rotate the object around it

---

<div class="post-metadata">

**Author:** ![Incipita](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/incipita/32/878973_2.png) [@Incipita](https://forums.unrealengine.com/u/Incipita)\
**Post date:** [August 9, 2022, 3:19am UTC](https://forums.unrealengine.com/t/rotate-a-mesh-around-its-center-using-quaternion/444575/5 "2022-08-09T03:19:07Z")

</div>

To orientation vector dont exits anymore, new name ?

---

<div class="post-metadata">

**Author:** ![Omorote\_Hideoshi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Omorote\_Hideoshi](https://forums.unrealengine.com/u/Omorote_Hideoshi)\
**Post date:** [July 26, 2023, 11:34am UTC](https://forums.unrealengine.com/t/rotate-a-mesh-around-its-center-using-quaternion/444575/6 "2023-07-26T11:34:53Z")

</div>

Just for the future - in C++ you can simply rotate by FQuats

```
const FQuat curretnQuatRotation = FQuat(YOUR FRotator Rotation);
const FQuat CurRelRotQuat = FQuat(FRotator(DeltaPitch, DeltaYaw, DeltaRoll));
const FQuat NewRelRotQuat = CurRelRotQuat * curretnQuatRotation;

```

In blue print simple use Add Local Rotation function of the object.
