Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

Quick question on making a matrix class

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

Hi, I want to make a simple matrix class, and I wanted to know for the columns and rows should I have its variables like so: float* rows; float* columns; int rowsCount; int columnsCount; or are most calculations with matrices involve 3columns x 3rows? As that what alot of my calculations seem to involve. eg float rows[3], columns[3]; and should I make them public or private(because in my vector3 class, i was told to make the x,y,z public)? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Quote:
and should I make them public or private(because in my vector3 class, i was told to make the x,y,z public)?
See this thread for some discussion on the public/private issue. Or, just take the following advice from me, who is not a professional, and is really in no position to be giving out advice on these boards, but is going to do so anyway and say:

Make. Them. Private.

As for choosing an internal representation for your matrix data, I'm not sure what the absolute best method is. Options include 'm11, m12', static 1d array, static 2d array, array of vectors, dynamic run-time sized, compile-time sized, etc. I currently use a static 2d array in my basic 2x2, 3x3, and 4x4 matrix classes, but I may change that at some point. Which, incidentally, serves as an example of why to make data private: it allows you, among other things, to change or improve the internal representation or handling of member data without breaking code outside the class.

There are a lot of considerations regarding internal matrix representation, and I too would be interested in hearing from experienced programmers on the issue. (I know some people are primarily concerned with platform-specific performance tweaks, but for me at least the main concern is portability.)

Share this post


Link to post
Share on other sites
I think I might also just use a 3x3 matrix. It seems that is all I require for my 3d calculations anyway. As all I am going to be using it for is the angular momentum/velocity calculations and a volume calculation anyway.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!