x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

[Closed] Convert a quaternion from world space to component space

Hi,

I am using quaternions to update an object's rotation. I need to compute the local-space value of a quaternion from its world-space value, but I can't manage to found how to.do it.

Any ideas ?

Product Version: Not Selected
Tags:
more ▼

asked Aug 25 '14 at 09:20 PM in C++ Programming

avatar image

StrangerGwenn
594 53 63 132

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

The question has been closed Apr 28 '15 at 07:42 AM by StrangerGwenn for the following reason:

The question is answered, right answer was accepted


2 answers: sort voted first

Here what i use, get Rotator from FQuat then get the local rotator then converse back to Quat

 FQuat WorldQuat;
 FRotator WorldRotator = WorldQuat.Rotator();

 FTransform ParentWorldTransform;

 FVector Forward = ParentWorldTransform.InverseTransformVector(FRotationMatrix(WorldRotator).GetScaledAxis(EAxis::X));
 FVector Right = ParentWorldTransform.InverseTransformVector(FRotationMatrix(WorldRotator).GetScaledAxis(EAxis::Y));
 FVector Up = ParentWorldTransform.InverseTransformVector(FRotationMatrix(WorldRotator).GetScaledAxis(EAxis::Z));

 FMatrix RotMatrix(Forward, Right, Up, FVector::ZeroVector);

 FQuat LocalQuat = RotMatrix.ToQuat();
more ▼

answered Aug 26 '14 at 02:25 AM

avatar image

Duncan Dam
3.1k 121 50 164

avatar image StrangerGwenn Aug 26 '14 at 06:49 AM

Thanks ! I guess I need to initialize ParentWorldTransform using GetComponentTransform() on the root component ?

The code seems to work - I'll be back tomorrow for more info on it. Thanks !

avatar image Duncan Dam Aug 26 '14 at 07:06 AM

Yeah, you can get any transform if you want as long as it from same Space with Quaternion you want to converse to local.

avatar image StrangerGwenn Aug 27 '14 at 09:48 PM

Confirmed working! Thanks !

avatar image Steazy Sep 26 '16 at 11:48 PM

This seems very logical but also seems computationally intensive. What are the advantages over the more traditional approach?

 FQuat LocalQuat = (ParentWorldTransform.GetRotation().Inverse() * WorldQuat);

Other than that the FQuat multiplication order in UE is super confusing (maybe that's just to me).

Often I double check by referencing FTransform::GetRelativeTransform(const FTransform& Other)'s implementation.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hey Gween if i was you i'll rotation matrix because anyway your problem is a mathematic one and what you need to do is to convert value from one coordinate system to another am i right ?

As i understand you the global values of your rotation related to the origin of the level (0,0,0)

so "All you need" to do is to find the matrix to pass from one coordinate system to another.

  1. First you'll probably need made a change of base

  2. Do others stuff

The best advice i can give you is take a look at mathematic how to Pass from one coordinate system to another. All Good Linear algebra book will have a 3d section and how do it.

Personnally i always keep my book around me.

If you need a concrete example i can build you one or if you need help just tell me

gamer08

more ▼

answered Aug 25 '14 at 11:14 PM

avatar image

gamer08
266 17 17 36

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question