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 3452928
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:18:55+00:00 2026-05-18T09:18:55+00:00

I’m terrible with matrix maths but I have a situation where I need to

  • 0

I’m terrible with matrix maths but I have a situation where I need to scale one. The matrix is an instance of a custom class defined here and my scaling object is a vector containing 3 floats (x,y,z). I’d like the actual code I need rather than a generic explanation because I’ve already gone down that path and just don’t understand the maths involved. Fortunately what I’m trying to accomplish is reasonably trivial once I can scale the matrix.

To clarify here is the code I’m updating. It iterates over a hierarchy of linked objects with relative transforms and updates mat& to an absolute transform:

void LocalModelPiece::GetPiecePosIter(CMatrix44f* mat) const
{
if (parent) {
    parent->GetPiecePosIter(mat);
}

if (pos.x || pos.y || pos.z) { mat->Translate(pos.x, pos.y, pos.z); }
// --> My problem is here. There is no Scale() method, I need one. <--
if (scale.x!=1.0f || scale.y!=1.0f || scale.z!=1.0f) { mat->Scale(scale.x, scale.y, scale.z); }
if (rot[1]) { mat->RotateY(-rot[1]); }
if (rot[0]) { mat->RotateX(-rot[0]); }
if (rot[2]) { mat->RotateZ(-rot[2]); }

}

  • 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-05-18T09:18:56+00:00Added an answer on May 18, 2026 at 9:18 am

    I looked at the API link you provided, and based on that, this is how I would implement a scaling method for the matrix class so that it’s consistent with the existing Translate() and Rotate() methods. That is, it does a right side multiplication with a scaling matrix.

    Though personally I find it a bit weird, because the API uses OpenGL style matrices. That means that a right side multiplication applies the new transformation before all the other transformations that exist in the matrix, where as left side multiplication would apply it after the other transformations. So I’m not sure if that’s what you want here. You might have to do all the transformations in the reverse order or do a left side multiplication yourself.

    void CMatrix44f::Scale(float scalex, float scaley, float scaley) 
    {
      /* the function should be equivalent to doing this:
      CMatrix44f scalemat;
      scalemat[0] = scalex;
      scalemat[5] = scaley;
      scalemat[10] = scalez;
      *this = Mul(scalemat);
      */
    
      m[0] *= scalex;
      m[1] *= scalex;
      m[2] *= scalex;
      m[3] *= scalex;
    
      m[4] *= scaley;
      m[5] *= scaley;
      m[6] *= scaley;
      m[7] *= scaley;
    
      m[8] *= scalez;
      m[9] *= scalez;
      m[10] *= scalez;
      m[11] *= scalez;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I need to clean up various Word 'smart' characters in user input, including but
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

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.