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

  • Home
  • SEARCH
  • 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 834019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:36:41+00:00 2026-05-15T04:36:41+00:00

I’ve been doing some reading on transforming Vector3 with matrices, and am tossing up

  • 0

I’ve been doing some reading on transforming Vector3 with matrices, and am tossing up digging deeper into the math and coding this myself versus using existing code. For whatever reason my school curriculum never included matrices, so I’m filling a gap in my knowledge. Thankfully I only need a few simple things, I think.

Context is that I’m programming a robot for the RoboCup 3D league. I’m coding it in C# but it’ll have to run on Mono. Ideally I wouldn’t use any existing graphics libraries for this (WinForms/WPF/XNA) as all I really need is a neat subset of matrix transformations.

Specifically, I need translation and x/y/z rotations, and a way of combining multiple transformations into a single matrix. This will then be applied to my own Vector3 type to produce the transformed Vector3.

I’ve read different advice about this. For example, some model the transformation with a 4×3 matrix, others with a 4×4 matrix.

Also, some examples show that you need a forth value for the vector’s matrix of 1. What happens to this value when it’s included in the output?

            [1 0 0 0]
[x y z 1] * [0 1 0 0] = [a b c d]
            [0 0 1 0]
            [2 4 6 1]

The parts I’m missing are:

  • What sizes my matrices should be
  • Compositing transformations by multiplying the transformation matrices together
  • Transforming 3D vectors with the resulting matrix

As I mostly just want to get this running, any psuedo-code would be great. Information about what matrix values perform what transformations is quite clearly defined on many pages, so need not be discussed here unless you’re very keen 🙂

  • 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-15T04:36:41+00:00Added an answer on May 15, 2026 at 4:36 am

    3 x 3 matrices can encode transformations such as rotation and reflection, but not translation. For that you need to add a fourth element and represent your vectors in terms of homogenous coordinates. It is possible to use non-square matrices for certain purposes, but if you want to be able to compose them in any order they should be square (because you can only multiply two matrices if the number of columns in the first is equal to the number of rows in the second).

    So, for your purposes you should use 4×4 matrices and 4-element homogenous vectors, adding a fourth w coordinate with value 1.

    Applying a transformation to a bunch of vectors is simply a matter of multiplying.

    Traditionally the vectors are represented as columns and the matrix goes on the left. You represent them above as rows and multiply on the right. Both are valid, but the transformation matrix needs to be transposed between the two cases. The matrix you show has the translation values along the bottom, which is correct for your multiplication order.

    After the vectors have been transformed, you need to divide through by the w coordinate to scale x, y and z back to conventional 3-space.

    In C-ish pseudocode, using a row-vector convention:

    Vector transform (Vector v, Matrix m)
    {
        Vector result;
        for ( int i = 0; i < 4; ++i )
           result[i] = v[0] * m[0][i] + v[1] * m[1][i] + v[2] + m[2][i] + v[3] * m[3][i];
        result[0] = result[0]/result[3];
        result[1] = result[1]/result[3];
        result[2] = result[2]/result[3];
        return result;
    }
    

    A sequence of transformations can be composed by multiplying the matrices for each together in turn. Note that matrix multiplication is not commutative, so the order in which you multiply is important. In turn, this means it is important whether you are multiplying row vectors on the left or columns on the right. If you multiply A x B x C, then with column vectors that is the same as performing transformation C first, then B, then finally A. With row vectors it is A first, then B and then C. So it is important to keep everything consistent when constructing, composing and applying your transformations.

    Again, in pseudocode that should be consistent with transform above:

    Matrix compose (Matrix first, Matrix second)
    {
        Matrix result;
        for ( int i = 0; i < 4; ++i )
            for ( int j = 0; j < 4; ++j )
                result[i][j] = first[i][0] * second[0][j]
                               + first[i][1] * second[1][j]
                               + first[i][2] * second[2][j]
                               + first[i][3] * second[3][j];
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.