Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8182251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:48:02+00:00 2026-06-07T00:48:02+00:00

I am a little confused on how exactly postScale method calculates the values of

  • 0

I am a little confused on how exactly postScale method calculates the values of matrix.
Here is the code:

Matrix m1 = new Matrix();
float[] values = { 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f };
m1.setValues(values);
Matrix m2 = new Matrix(m1);

m1.preScale(2f, 3f); //result: 2, 6, 3, 8, 15, 6, 14, 24, 9
m2.postScale(2f, 3f); //result: 1, 2, 3, 6, 7.5, 9, 3.5, 4, 4.5

Documentation says that the result of preScale is (Matrix * scale) and the result of postScale is (scale * Matrix). But the results vary if I calculate the matrices manually.

multiply from right:

1 2 3 | 2 0 0   2   6 3
4 5 6 | 0 3 0 = 8  15 6
7 8 9 | 0 0 1   14 24 9

multiply from left:

2 0 0 | 1 2 3    2  4  6
0 3 0 | 4 5 6 = 12 15 18
0 0 1 | 7 8 9    7  8  9

…left multiplication (postScale) returns a different result than I expected.

I even looked into the native implementation (Matrix_Delegate.java). But I don’t know where the problem is. Is there something I’m missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:48:07+00:00Added an answer on June 7, 2026 at 12:48 am

    After setConcat (in android/external/skia/src/core/SkMatrix.cpp ) multiples two matrices of which at least one is a perspective matrix, it calls a method called “normalize_perspective”. If the last cell of the matrix (the bottom right corner, mat[2][2] if zero-indexed, mat[8] in this representation) is greater than 1, it divides every number in the matrix by two. That certainly describes what we’re seeing here.

    But how does our friendly matrix come to be considered a perspective matrix? Well. When we do setValues(), the type gets set as Unknown. When setConcat calls getType, it sees “unknown” and decides to do something about that. It calls computeTypeMask. computeTypeMask looks at the third column, sees that it’s not [ 0 0 1 ], and slaps a Perspective label on the type of the matrix. This happens to your m2.

    But why is all this only an issue for postScale? preScale (unless the Skia library is compiled in fixed-point mode) does the scaling itself, so it never gets into setConcat to strike upon these rocky shoals.

    Why is normalize_perspective a good idea? Damned if I know. It’s probably something to do with the expected 2d graphics applications for these particular routines.

    What can you do about all this? If you’re targeting API level 11 or greater, then renderscript’s Matrix3f is probably your friend. If not, I’m sorry, D-Fox, your matrix implementation is in another castle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a little confused by the class code. Here's what I'm trying to do:
I'm a little confused as to what exactly is going on here. For instance...
I am a little bit confused by the PHP function declare . What exactly
I'm a little confused about which jQuery method and/or selectors to use when trying
I'm a little confused to why my query is not returning exactly what I
As always, i'm a little confused. Here https://community.jboss.org/wiki/ModularWebAppsWithJSF2 i've learned that it is easy
I'm a little confused here. I have my POCO classes created with the entity
I'm a little confused about when exactly my Property is being initialized. Suppose I
I'm a little bit confused with the use of @. In the following code
I am a little confused on HttpServlet usage of @Path(/path) with an @POST method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.