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

Affine transformation helpers functions for Matrix classes #10124

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

IanLilleyT
Copy link
Contributor

@IanLilleyT IanLilleyT commented Feb 22, 2022

This PR fills in some gaps in Matrix2, Matrix3, and Matrix4 for affine transformations. This includes:

  • setScale - for Matrix2, Matrix3
    • exists in Matrix4 already
  • setUniformScale - for Matrix2, Matrix3, Matrix4
  • multiplyByUniformScale - for Matrix2, Matrix3
    • exists in Matrix4 already
  • setRotation - for Matrix2, Matrix3, Matrix4
  • getRotation - for Matrix2, Matrix4
    • exists in Matrix3 already
  • fromRotation - for Matrix4
    • Matrix2 and Matrix3 already have their own versions of this

Also did some cleanup in the specs so that all tests are grouped by:

  • Capability tests
  • Missing parameter tests
  • Missing result parameter tests

Misc:

  • Inlined most of the math for better performance
  • Coverage is 100%

@cesium-concierge
Copy link

Thanks for the pull request @IanLilleyT!

  • ✔️ Signed CLA found.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.

@IanLilleyT IanLilleyT force-pushed the matrixFunctions branch 2 times, most recently from 015aec3 to e0df525 Compare February 22, 2022 17:42
@ggetz
Copy link
Contributor

ggetz commented Feb 23, 2022

Thanks @IanLilleyT! @ebogo1 can you please review?

Copy link
Contributor

@ebogo1 ebogo1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just wanted to double check that the inline math in Matrix2 and Matrix3 was what you intended.

const scaleRatioX = scale.x / existingScale.x;
const scaleRatioY = scale.y / existingScale.y;

result[0] = matrix[0] * scaleRatioX;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this just call multiplyByScale like Matrix4 does? Unless this is what you meant by inlining more of the math.


const scale = Matrix2.getScale(matrix, scaleScratch4);

result[0] = rotation[0] * scale.x;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - there are a couple other places in this file so I'll stop commenting on each one. Maybe the uniformScale function doesn't need it because it's not using a scratch vec2.

@IanLilleyT
Copy link
Contributor Author

Yep the inline math is intended and should give slightly better performance and IMO doesn't hurt readability. There are some areas in this PR where the function was already implemented but I changed it to be inline math for consistency.

@ebogo1 ebogo1 merged commit 178cd58 into main Feb 23, 2022
@ebogo1 ebogo1 deleted the matrixFunctions branch February 23, 2022 20:49
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

Successfully merging this pull request may close these issues.

None yet

4 participants