http://forum.celestialmatters.org/

What vector library is used by Celestia.SCI?
http://forum.celestialmatters.org/viewtopic.php?f=2&t=947
Page 1 of 1

Author:  375gnu [ Sun, 21-10-18, 19:41 GMT ]
Post subject:  What vector library is used by Celestia.SCI?

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

Author:  t00fri [ Sun, 21-10-18, 20:44 GMT ]
Post subject:  Re: What vector library is used by Celestia.SCI?

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

Author:  375gnu [ Mon, 22-10-18, 18:45 GMT ]
Post subject:  Re: What vector library is used by Celestia.SCI?

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.

Author:  t00fri [ Mon, 22-10-18, 20:37 GMT ]
Post subject:  Re: What vector library is used by Celestia.SCI?

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/