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

Resolve Inconsistency in Matrix3 and Matrix4 rotateY Implementations #315

Closed
wants to merge 1 commit into from

Conversation

tlserver
Copy link
Contributor

@tlserver tlserver commented Mar 4, 2024

This PR addresses the issues highlighted in #261 and is related to the discussions in #262 and #300, as well as the historical context provided by #69.

In reference to the conversation in #262, two primary concerns were identified:

  1. The change introduced test failures.
  2. There was an inconsistency between the rotateY methods in the Matrix3 and Matrix4 classes.

Here's a summary of the remedial actions taken in this PR:

This PR is similar to #262. The only difference is that this PR also includes a negated rotation angle in the obb3 test.

For issue (1), the test expectations have been updated to reflect the correct signs, ensuring that all tests now pass.

Regarding issue (2), upon further investigation, it was found that the Matrix4 class already had the correct implementation since August 23, 2014. However, the Matrix3 class has not been updated to match this, leading to a longstanding inconsistency between the two. This PR rectifies the Matrix3 rotateY method to align with the Matrix4 implementation, bringing them into consistency.

  // Matrix3
  /// Turns the matrix into a rotation of [radians] around Y
  void setRotationY(double radians) {
    final c = math.cos(radians);
    final s = math.sin(radians);
    _m3storage[0] = c;
    _m3storage[1] = 0.0;
    _m3storage[2] = -s;
    _m3storage[3] = 0.0;
    _m3storage[4] = 1.0;
    _m3storage[5] = 0.0;
    _m3storage[6] = s;
    _m3storage[7] = 0.0;
    _m3storage[8] = c;
  }
  
  // Matrix4
  /// Sets the upper 3x3 to a rotation of [radians] around Y
  void setRotationY(double radians) {
    final c = math.cos(radians);
    final s = math.sin(radians);
    _m4storage[0] = c;
    _m4storage[1] = 0.0;
    _m4storage[2] = -s;
    _m4storage[4] = 0.0;
    _m4storage[5] = 1.0;
    _m4storage[6] = 0.0;
    _m4storage[8] = s;
    _m4storage[9] = 0.0;
    _m4storage[10] = c;
    _m4storage[3] = 0.0;
    _m4storage[7] = 0.0;
    _m4storage[11] = 0.0;
  }

This PR is similar to #262. The only difference is that this PR also includes a negated rotation angle in the obb3 test.

By merging this PR, we will resolve the inconsistencies and adhere to the mathematical definitions of rotation matrices, as expected by the users of the vector_math.dart library.

I look forward to your feedback and to further improving the library.

Copy link

google-cla bot commented Mar 4, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@coveralls
Copy link

Coverage Status

coverage: 26.33%. remained the same
when pulling d5b488e on tlserver:master
into 3706feb on google:master.

@tlserver
Copy link
Contributor Author

tlserver commented Mar 5, 2024

Please go to #317 since the head branch of this PR cannot be changed.

@tlserver tlserver closed this Mar 5, 2024
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.

2 participants