Using FMatrix For 3x3?

Is there a way to use FMatrix in a 3x3 manner functionally equivalent to the following c++ code?

Matrix3::Matrix3 () {
	for (int i=0; i<3; i++) {
		for (int k=0; k<3; k++) {
			if (i == k)
				m[i][k] = 1;
				m[i][k] = 0;

Matrix3::Matrix3 (double a[3][3]) {
	for (int i=0; i<3; i++)
		for (int k=0; k<3; k++)
			m[i][k] = a[i][k];

Matrix3& Matrix3::operator = (const Matrix3 &n) {
	for (int i=0; i<3; i++)
		for (int k=0; k<3; k++)
			m[i][k] = n.m[i][k];
	return *this;

Vector3 Matrix3::operator * (const Vector3 &v) const {
	return Vector3
		(v.x*m[0][0] + v.y*m[0][1] + v.z*m[0][2],
		 v.x*m[1][0] + v.y*m[1][1] + v.z*m[1][2],
		 v.x*m[2][0] + v.y*m[2][1] + v.z*m[2][2]);
1 Like

there seesms to be implemrntation of this

Yes, if you use it as homogenous matrix, so it looks like this

x1 x2 x3 0
y1 y2 y3 0
z1 z2 z3 0
0  0  0  1

So your first constructor is building the identity matrix, which would be

FMatrix A = FMatrix::Identity;

The second constructor where you copy a 3x3 matrix. In Unreal you cant directly do that, but indirectly using the FPlane constructor

FMatrix A( FPlane(a[0][0], a[0][1], a[0][2], 0),
            FPlane(a[1][0], a[1][1], a[1][2], 0),
            FPlane(a[2][0], a[2][1], a[2][2], 0),
            FPlane(0,       0,       0,       1));

Or you can set it afterwardst

FMatrix A = FMatrix::Identity;
for (int i=0; i<3; i++)
     for (int k=0; k<3; k++)
         A.M[i][k] = a[i][k];

The third one is obviously the equal operator

FMatrix B = A;

The vector multiplication is like seeing the FMatrix as a Transformation applied to a vector. So in unreal it is

FVector w = A.TransformVector(v)

You can look at the FMatrix API to get more information :wink: