It is currently Thu, 15-11-18, 13:04 GMT

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun, 21-10-18, 19:41 GMT 
Offline

Joined: Tue, 25-03-14, 14:29 GMT
Posts: 3
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


Top
 Profile  
 
PostPosted: Sun, 21-10-18, 20:44 GMT 
Offline
Site Admin
User avatar

Joined: Fri, 31-08-07, 7:01 GMT
Posts: 4585
Location: Hamburg, Germany
375gnu,
Quote:
void
Frustum::transform(const Mat4f& m)
{
Matrix4f m2 = Map<Matrix4f>(&m[0][0]);
transform(m2);
}


we use Eigen 3.x right from the start and have applied many cross checks all along.
I do understand your argument, but as far as I can see, such pitfalls are avoided in celestia.Sci. We also don't invoke the Celestia code from frustum.cpp that you displayed initially.

Thanks for letting us know your findings.

Fridger

_________________
Image


Top
 Profile  
 
PostPosted: Mon, 22-10-18, 18:45 GMT 
Offline

Joined: Tue, 25-03-14, 14:29 GMT
Posts: 3
t00fri wrote:
we use Eigen 3.x right from the start and have applied many cross checks all along.
I do understand your argument, but as far as I can see, such pitfalls are avoided in celestia.Sci. We also don't invoke the Celestia code from frustum.cpp that you displayed initially.


Good to hear. But when we'll see your version? Of course I know your answer: "When it's ready", but I (and I assume not only me) would hear some estimations.


Top
 Profile  
 
PostPosted: Mon, 22-10-18, 20:37 GMT 
Offline
Site Admin
User avatar

Joined: Fri, 31-08-07, 7:01 GMT
Posts: 4585
Location: Hamburg, Germany
375gnu,
Quote:
But when we'll see your version? Of course I know your answer:


I'll reply to you once I have an answer that you don't know ;-)

Cheers,
Fridger

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group