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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:18:23+00:00 2026-06-04T15:18:23+00:00

I am trying to create a simple matrix library in C++ that I will

  • 0

I am trying to create a simple matrix library in C++ that I will hopefully be able to use in game development afterwards.

I have the basic implementation done, but I have just realized a problem with storing only one matrix per object: the rotation order will get mixed up fairly quickly.

To the best of my knowledge: AB != BA

Therefore, if I am continually multiplying arbitrary rotations to my matrix, than the rotation will get mixed up, correct? In my case, I need to rotate globally on the Y axis, and locally on the X axis (and locally on the Z axis would be nice as well). These seem like the qualities of the average first person shooter. So by “mixed up”, I mean that if I go to rotate on the Y axis (or Z axis), then it will start rotating around the local X axis, instead of the intended axis (if that makes any sense).

So, these are the solutions I came up with:

  1. Keep 3 Euler angles, and rebuild the matrix in the correct order when one angle changes
  2. Keep 3 Matrices, one for each axis
  3. Somehow destruct the matrix during multiplication, and reconstruct it properly afterwards (?)

Or am I worrying about nothing? Are my qualms false, and the order will somehow magically solve itself?

  • 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-04T15:18:25+00:00Added an answer on June 4, 2026 at 3:18 pm

    You are correct that the order of rotation matrices can be an issue here.

    Especially if you use Euler angles, you can suffer from the issue of gimbal lock: let’s say your first rotation is +90° positive “pitch”, meaning you’re looking straight upward; then if the next rotation is +45° “roll”, then you’re still just looking straight up. But if you do the rotations in the opposite order, you end up looking somewhere different altogether. (see the Wikipedia link for an illustration that makes this clearer.)

    One common answer in game development is what you’ve got in (1): store the Euler angles independently, and then build the rotation matrix out of all three of them at once every time you want to get the object’s orientation in world space.

    Another common solution is to store rotation as an angle around a single axis, rather than as Euler angles. (That is often less convenient for animators and player motion.)

    We also often use quaternions as a more efficient way of storing and combining rotations.

    Each of the links above should take you to an article illustrating the relevant math. I also like Eric Lengyel’s Mathematics for 3D Game Programming and Computer Graphics book, which explains this whole subject very well.

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

Sidebar

Related Questions

I am trying to create a simple Automator droplet that will take the style.less
I'm trying to create simple function that will work two ways. Basically, when I
Just trying to create a simple method that counts up 1 on the tally
Im trying to create a simple loop that creates 50 buttons, adds them to
I am trying to create a simple MongooseJS example program that gets a list
I`m trying to create simple QML application. I have QtSDK installed with latest QtCreator.
I'm trying to create simple ExtJs application that manages Users and User's Roles. Set
I am trying to use webkit's support for CSS3 transform: matrix3d(<matrix>) to create a
I was trying to create simple program that would perform some trivial operation with
I'm trying to create simple slot machine with three slots. Each slot will generate

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.