question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

matrix.extractRotation() returns incorrect rotation matrix when scale is negative

See original GitHub issue

setFromRotationMatrix is incorrect when scale is negative on any axis. matrix.decompose returns correct rotation.

I assume this is because the following code is missing in setFromRotationMatrix (present in matrix.decompose):

// if determine is negative, we need to invert one scale
var det = this.determinant();
if ( det < 0 ) sx = - sx;

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
WestLangleycommented, May 29, 2018

I would probably prefer to remove it, but I added a comment and patched it, instead.

1reaction
WestLangleycommented, May 28, 2018

In your case, are you referring to Quaternion or Euler?

In either case, you have to pass in a pure rotation matrix. (That is where the method name comes from.)

See the code comment:

// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Given this transformation matrix, how do I decompose it into ...
Extract Rotation Divide the first three column vectors by the scaling factors you just found. Your matrix should now look like this (remember...
Read more >
Reset rotation matrix without losing scale - Stack Overflow
Most of the rotate() methods out there add rotation to a current one multiplying the current matrix with the new rotation. I need...
Read more >
How to assign Matrix4x4 to Transform? - Unity Forum
Do I really have to extract position, rotation, and scale values from the matrix, or there is a nice and simple way to...
Read more >
Struct Matrix4d - OpenTK
Represents a 4x4 matrix containing 3D rotation, scale, transform, and projection with double-precision components. Implements. System.IEquatable<Matrix4d> ...
Read more >
hou.Matrix4 - SideFX
A 4×4 matrix of floating point values. 4×4 matrices are typically used in Houdini to represent a 3D transformation (e.g. some combination of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found