Rotate a mesh around it's center using quaternion

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

and this is the cylinder i want to rotate.

Imgur

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

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

i would appreciate any help.

Many Thanks

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

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.

1 Like

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

my current blueprint setup is

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.

i was able to solve the problems using those nodes.

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

To orientation vector dont exits anymore, new name ?

1 Like

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.

1 Like