ok i have to make a matrix class for a math library and im now Very lost with what im ment to do or how to do it the code i have so far is:

#include <iostream>
#include <math.h>
#include "Vector2.h"

class Matrix
{
private:
float data[3][3];

public:
Matrix()
{
}

~Matrix()
{
}

float Matrix::GetData(int Col, int Row )
{ 
return data[ Col ][ Row ];
}

float Matrix:: SetData(int Col, int Row )
{ 
return data[ Col ][ Row ];
}

void SetTranslation( const vector2 &Translation );

void GetTranslation( const vector2 &Translation );

void TransformPoint( vector2 &Point );
};

inline void Matrix:: SetTranslation( const vector2 &Translation )
{
}

inline void Matrix::GetTranslation( const vector2 &Translation )
{
}

inline void Matrix::TransformPoint( vector2 &Point )
{
//Transform and translate the point
}

and i need to now create operator functions for


Matrix + Matrix


how would i do this or can someone point me in the right direction on how to do it

Tell us how you would add two matrices on paper.

[a b] + [1 2 ] = [ a + 1 b + 2]
[c d] [3 4 ] [c + 3 d + 4]

but how would i code it?

like this???

float Matrix::Add(data )
	{	
		[1, 0, 0] + [1, 0, 0];
		[0, 1, 0] + [0, 1, 0];
		[0, 0, 1] + [0, 0, 1];
	}

[a b] + [1 2 ] = [ a + 1 b + 2]
[c d] [3 4 ] [c + 3 d + 4]

but how would i code it?

like this???

float Matrix::Add(data )
	{	
		[1, 0, 0] + [1, 0, 0];
		[0, 1, 0] + [0, 1, 0];
		[0, 0, 1] + [0, 0, 1];
	}

lol...
You need to add their respective elements like this..

int sum[3][3];
for(int i=0;i<3;i++)
 for(int j=0;j<3;j++)
  sum[i][j]=A[i][j]+B[i][j];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.