Sign in to follow this  

4D matrix / vector addition?

This topic is 3860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to write a basic math library for use in games. I'm writing support for 4D matrices and vectors because I want to be able to use a single matrix to describe both rotations and translations. But I don't know of a clean way to handle addition between two 4D matrices or two 4D vectors. For example, if I want to sum up a bunch of vectors and then transform the sum by some matrix, I'll probably want the w coordinate of the sum vector to be 1, but if I just do straight vector addition it will end up being more than 1. I could just ignore the fourth dimension when performing addition, but this seems like an ugly hack. This seems like it would be a fairly common problem, so I'm just wondering if there is some sort of convention on how to perform addition.

Share this post


Link to post
Share on other sites
Can you give an example of a case where you would want to add 4x4 matrices, or add 3D points (represented by 4D vectors) and then transform the result?

Also, I'll give some advice that's often repeated around here: if your goal is to make games (rather than, say, exercise your programming skills or build basic math knowledge), use a pre-existing math library rather than writing your own. In other words, don't write a math library just because you need a math library (that work has already been done many times over by others).

If you do want to look into existing math libraries, options that come to mind include WildMagic, SVL, and the CML (the latter of which I am co-author).

Share this post


Link to post
Share on other sites

This topic is 3860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this