question

Serge A avatar image
2 Likes"
Serge A asked Serge A commented

Vec4 and quaternions

I noticed that FlexSim 2025 documentation mentions new classes, Vec4 and Mat4.

I'm just curious, are you planning to support quaternion math?

It would be really neat if we could use Vec4 to represent and calculate FlexSim rotations.

https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation

FlexSim 24.2.2
quaternionvec4
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Joerg Vogel avatar image Joerg Vogel commented ·

@Serge A, would this not be a case for a Python program call?

0 Likes 0 ·
Serge A avatar image Serge A Joerg Vogel commented ·

The third party libraries for quaternions were already available before Vec4, Boost QVM for C++ or several Python libraries, but it's a huge convenience to have something built in FlexSim. Like Vec3 has dot, cross, project, projectRotation and normalized, they are incredibly useful and many geometric calculations can be done in a relatively simple Flexscript code.

Quaternions can define rotations as an arbitrary 3D axis and an angle, and in some situations it is a more straightforward way than Euler angles used in FlexSim by default (rx, ry, rz). The product of two quaternions also shows what is the effective rotation axis of a combination of two rotations. It's not at all . Conversion from one representation to another is not rocket science, but it's easy to make a mistake. https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles

I don't know what exactly was the motivation to add Vec4 to Flexscript, but it immediately came to my mind that now there is an opportunity to improve geometric capabilities of Flexscript.

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Serge A commented ·
We work with ABB Robots. They use quaternions.
0 Likes 0 ·
Logan Gold avatar image Logan Gold ♦♦ commented ·

Hi @Serge A, was my answer helpful? If so, please click the "Accept" button at the bottom of the answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·

1 Answer

Logan Gold avatar image
0 Likes"
Logan Gold answered Serge A commented

Hey @Serge A, there are no current plans to add anything to FlexSim related to quaternion math. If you want to post an Idea with some more details about what you'd like to see in FlexSim, we can add that as an improvement suggestion to the development list.

Otherwise, it looks like you might be able to do quaternion math in Python, so you might be able to connect to an external Python script and do it that way.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Serge A avatar image Serge A commented ·
Thank you, that's clear.
0 Likes 0 ·