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

Edited 6 Years Ago by deorcar: n/a

[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];
	}

Edited 6 Years Ago by deorcar: n/a

[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];
This question has already been answered. Start a new discussion instead.