Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: expand transformation matrix to 4x4xN ? #113

Open
oqilipo opened this issue Oct 9, 2020 · 6 comments
Open

Feature: expand transformation matrix to 4x4xN ? #113

oqilipo opened this issue Oct 9, 2020 · 6 comments

Comments

@oqilipo
Copy link
Contributor

oqilipo commented Oct 9, 2020

Hi David

What do you think about expanding the transformation matrices to a third dimension [4x4xN]?

That would introduce the possibility to transform multiple points [Nx3], vectors [Nx3], etc. with multiple transformation matrices [4x4xN].

Kind regards

@dlegland
Copy link
Member

Hi,

yes, sounds good! I think some functions (maybe written by you?) already follow this convention. The main functions to update would be the "transformXXX"ones. Do you see others?

@oqilipo
Copy link
Contributor Author

oqilipo commented Oct 15, 2020

I think the following files:

composeTransforms3d.m
createBasisTransform3d.m
createRotation*.m
createScaling3d.m
createTranslation3d.m
eulerAnglesToRotation3d.m
isTransform3d.m
recenterTransform3d.m
rotation3dAxisAndAngle.m
rotation3dToEulerAngles.m
transform*3d.m

Actually more work than I thought. ;-)

One question is: what is the most elegant, efficient and consistent way to implement this feature?

Other question is: what conventions should be used for multiple input variables?
For example for transformLine3d.m
Input: Line [1x6], TFM [4x4] -> Output: Line [1x6]
Input: Line [1x6], TFM [4x4xN] -> Output: Line [Nx6]
Input: Line [Nx6], TFM [4x4xN] -> Output: Line [Nx6]
Input: Line [Nx6], TFM [4x4] -> Output: Line [Nx6]
Input: Line [Mx6], TFM [4x4xN] -> Output: error

Kind regards

@dlegland
Copy link
Member

Hi,

yes, the number of functions devoted to transforms start to be large! However, all the creation functions can be left as is for the moment. This reduces the work.

The output for multiple inputs may be problematic...
In the case of M lines and N transforms, a possible solution would be to output a M-by-6-by-N array (keeping last index for the transformation index).

best regards,
David

@oqilipo
Copy link
Contributor Author

oqilipo commented Feb 18, 2021

Matlab introduced a new function that might help https://www.mathworks.com/help/matlab/ref/pagemtimes.html
However, I don't know when I will have the time to give it a try.

@men8th
Copy link

men8th commented Sep 8, 2023

Other question is: what conventions should be used for multiple input variables? For example for transformLine3d.m
Input: Line [1x6], TFM [4x4] -> Output: Line [1x6]
Input: Line [1x6], TFM [4x4xN] -> Output: Line [Nx6]
Input: Line [Nx6], TFM [4x4xN] -> Output: Line [Nx6]
Input: Line [Nx6], TFM [4x4] -> Output: Line [Nx6]
Input: Line [Mx6], TFM [4x4xN] -> Output: error

If you are interested, with respect to the above, in my opinion you should aim to reproduce something comparable to the implicit expansion Matlab will do nowadays with incompatible sizes (https://uk.mathworks.com/help/matlab/matlab_prog/compatible-array-sizes-for-basic-operations.html)

@dlegland
Copy link
Member

dlegland commented Sep 8, 2023

Hi,
yes, I strongly agree with following the Matlab convention for implicit conventions. The bsxfun function is also used is several functions internally.

Reconsidering the question today, a solution could be as follow:

Input: Line [1x6], TFM [4x4] -> Output: Line [1x6]
Input: Line [Nx6], TFM [4x4] -> Output: Line [Nx6]
Input: Line [1x6], TFM [4x4xN] -> Output: Line [1x6xN]
Input: Line [Mx6], TFM [4x4xN] -> Output: Line [Mx6xN]

This way, we ensure consistent dimension of output argument.

Two improvements may be added:

  • when both inputs have same N, the use of an additionnal option may force to combine only inputs with same index, like keeping only the diagonal of the MxN matrix. I used such an approach for the distancePoints function
  • it could useful to have a squeeze function that transforms 1x6xN arrays into Nx6 arrays. Maybe something like "squeezeGeometry"?. Principle would be to squeeze all dimensions except the second one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants