Skip to content

Matrix3.rotationY provides incorrect matrix #261

Closed
@bluebaloon

Description

@bluebaloon

For pi/2 it gives result of
[0 0 -1]
[0 1 0]
[1 0 0]
which is incorrect.
It should be
[0 0 1]
[0 1 0]
[-1 0 0]
Rows are written in place of columns (like transpose).
Code should be corrected as given below.
/// 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;
}

Please check.

Activity

GhostCore07

GhostCore07 commented on Apr 9, 2022

@GhostCore07

Related to #69.
Looks like a bug.

moritzblume

moritzblume commented on Apr 19, 2022

@moritzblume
Contributor

I just stumbled over this bug, too. As it is implemented, the rotation would be clockwise which does not fit the norm (right-hand-rule) and is inconsistent with setRotationX and setRotationZ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @johnmccutchan@moritzblume@bluebaloon@GhostCore07

        Issue actions

          Matrix3.rotationY provides incorrect matrix · Issue #261 · google/vector_math.dart