You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.
Matrix3x2.ScaleVector returns new Vector2(M11, M22). This is only correct if M12 == M21 == 0. Here's an easy test:
var transform = Matrix3x2.Scaling(3.0f, 2.0f);
Debug.WriteLine($"Scaling: {transform.ScaleVector}");
// prints "Scaling: X:3 Y:2"
transform *= Matrix3x2.Rotation((float)(Math.PI / 2.0));
Debug.WriteLine($"Scaling: {transform.ScaleVector}");
// prints "Scaling: X:-1.311342E-07 Y:-8.742278E-08"
As explained in This Mathematics Stack Exchange answer, there is no real answer to "What is the scale vector of this matrix?". If you ignore the fact that the scaling can be the negative version of the rotation A + 180 degrees, you can calculate scale like this:
var scaleX = Math.Sqrt(transform.M11 * transform.M11 + transform.M12 * transform.M12);
var scaleY = Math.Sqrt(transform.M21 * transform.M21 + transform.M22 * transform.M22);
var cosA = transform.M11 / scaleX;
var cosB = transform.M22 / scaleY;
var sinA = transform.M21 / scaleY;
var sinB = transform.M12 / scaleX;
At this point, scaleX and scaleY are valid only if cosA == cosB and sinA == -sinB (within tolerance).
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Matrix3x2.ScaleVector
returnsnew Vector2(M11, M22)
. This is only correct if M12 == M21 == 0. Here's an easy test:As explained in This Mathematics Stack Exchange answer, there is no real answer to "What is the scale vector of this matrix?". If you ignore the fact that the scaling can be the negative version of the rotation A + 180 degrees, you can calculate scale like this:
At this point, scaleX and scaleY are valid only if cosA == cosB and sinA == -sinB (within tolerance).
The text was updated successfully, but these errors were encountered: