Jump to content
• Advertisement

4D matrix / vector addition?

This topic is 4190 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

Share on other sites
Advertisement
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

Share on other sites

• Advertisement
• Advertisement

• Popular Contributors

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5
• Advertisement

• 18
• 10
• 9
• 9
• 11
• Forum Statistics

• Total Topics
633694
• Total Posts
3013362
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!