Matrix definition issues

Hello all.

To follow up on ToonTank course, I’m trying to solidify my knowledge by working on a personnal project.
I want to program 6-axis industrial robot movements.
To do that, I need to do a lot of change of base calculations (global to local space) and consider not only translation but also rotations.
Matrices should be an easy way to do this, but I’m having trouble to define them.
I’ve tried the following :

• in .h file :

``````    FRotationTranslationMatrix T_Base(FRotator(), FVector());
``````
• in .cpp file :

``````  const FRotator& TempRot = BaseMesh->GetRelativeRotation();

const FVector& TempPos = BaseMesh->GetRelativeLocation();

T_Base(TempRot, TempPos);
``````

I get the following error message on T_Base :

``````il n'existe aucune fonction de conversion appropriée de "const FRotator" en "FRotator (*)()"
il n'existe aucune fonction de conversion appropriée de "const FVector" en "FVector (*)()"
``````

which should translate by something like :

``````There is no proper conversion function from "const FRotator" to "FRotator (*)()"
``````

Any idea why this not working?

There’s two issues with this.

1. You have stumbled upon “the most vexing parse”.
``````FRotationTranslationMatrix T_Base(FRotator(), FVector());
``````
This is actually a function declaration. This declares a function called `T_Base` that returns `FRotationTranslationMatrix` and takes two function pointers that have no parameters and return `FRotator` and `FVector` respecitively e.g.
``````FRotator Foo();
FVector Bar();

T_Base(Foo, Bar); // call T_Base passing the address of Foo and Bar
``````
This can be resolved using braces instead
``````// Any of these replacements of () to {} should work
FRotationTranslationMatrix T_Base{FRotator(), FVector()}; // just the outer
FRotationTranslationMatrix T_Base{FRotator{}, FVector{}); // just the inner
FRotationTranslationMatrix T_Base{FRotator{}, FVector{}}; // all
``````
2. If T_Base were fixed to be a variable of type `FRotationTranslationMatrix`
``````T_Base(TempRot, TempPos);
``````
This would be using the function call operator
``````FRotationTranslationMatrix::operator()(const FVector&, const FRotator&);
``````
as the variable has already been defined and initialised. You would need to use the assignment operator `=` to assign a new value.
``````T_Base = FRotationTranslationMatrix(TempRot, TempPos);
``````

Thanks a lot for the information!
I’ll try this

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.