Hi!

Original Celestia was moving away from its inhome vector library in Eigen direction. Today I have found a strange code in frustum.cpp:

**Code:**

void

Frustum::transform(const Mat4f& m)

{

Matrix4f m2 = Map<Matrix4f>(&m[0][0]);

transform(m2);

}

The problem is that celestia's

*Matrix4* uses row-major memory layout, but

*Eigen* by default uses column-major layout, so this means that

*m2* is a

**transposed** *m* actually! So this may indicate that celestia has some bugs in frustum (and plane) code.

Demo code:

**Code:**

Vec3f v1(1,2,3), v2(4,5,6), v3(7,8,9);

Mat3f m(v1,v2,v3);

std::cout << "Mat3f:\n";

for(int i=0;i<3;i++) {for(int j=0;j<3;j++) std::cout<<m[i][j] << ' ';std::cout<<'\n';}

std::cout << '\n';

std::cout << "Eigen::Matrix3f:\n";

Eigen::Matrix3f me = Eigen::Map<Eigen::Matrix3f>(&m[0][0]);

std::cout << me <<"\n\n";

for(int i=0;i<3;i++) {for(int j=0;j<3;j++) std::cout<<me(i, j) << ' ';std::cout<<'\n';}

std::cout <<"\n\n";

float mf[3][3] = {{1,2,3},{4,5,6},{7,8,9}};

std::cout << "Float[3][3]:\n";

for(int i=0;i<3;i++) {for(int j=0;j<3;j++) std::cout<<mf[i][j] << ' ';std::cout<<'\n';}

std::cout <<"\nEigen::Matrix3f:\n";

Eigen::Matrix3f mfe = Eigen::Map<Eigen::Matrix3f>(&mf[0][0]);

std::cout << mfe <<"\n\n";

for(int i=0;i<3;i++) {for(int j=0;j<3;j++) std::cout<<mfe(i, j) << ' ';std::cout<<'\n';}

And its result:

**Code:**

Mat3f:

1 2 3

4 5 6

7 8 9

Eigen::Matrix3f:

1 4 7

2 5 8

3 6 9

1 4 7

2 5 8

3 6 9

Float[3][3]:

1 2 3

4 5 6

7 8 9

Eigen::Matrix3f:

1 4 7

2 5 8

3 6 9

1 4 7

2 5 8

3 6 9