Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: The sf::Matrix3 class  (Read 3283 times)

0 Members and 1 Guest are viewing this topic.

Dolf

  • Newbie
  • *
  • Posts: 5
    • View Profile
The sf::Matrix3 class
« on: December 26, 2009, 01:08:32 pm »
Hello,

I'm having some issues with the sf::Matrix3 class. It might be that I am completely misunderstanding the class but I was just questioning some interface decisions here.

Why aren't there Get/Set functions for:
Scale()
Rotation()
Translation()

And why doesn't the header file say whether it's a row or column matrix? Or at least explain the lay-out so that I could create my own matrix class and create a conversion between mine and sf::Matrix3.

And even worse, why does it start counting from 1 instead of 0? If I create a matrix with an translation X and Y, this is how I managed to get those values back from the matrix:
float x = someMatrix( 3, 1 );
float y = someMatrix( 4, 1 ); // 4 should be outside the array in a 4x4 matrix ...  another point: why aren't there bounds checking asserts in the operator () ?

Thank you so much for reading my moaning about the Matrix3 class,

Dolf

Edit: And why is it in graphics instead of system?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
The sf::Matrix3 class
« Reply #1 on: December 26, 2009, 04:07:37 pm »
Hi

There's a simple answer to all of your questions: sf::Matrix3 is designed and optimized for my own internal usage, you're not supposed to use it directly. Nothing in the public API of SFML deals with matrices.

If you need a matrix class in your code you should definitely not use SFML's one.

Quote
And why doesn't the header file say whether it's a row or column matrix? Or at least explain the lay-out so that I could create my own matrix class and create a conversion between mine and sf::Matrix3.

Like I said it's not meant for public usage, but you can look at the source code to find out which layout it uses. But there's no point converting from/to sf::Matrix3, it's only used internally. Just focus on your own matrix class.

Quote
And even worse, why does it start counting from 1 instead of 0? If I create a matrix with an translation X and Y, this is how I managed to get those values back from the matrix:
float x = someMatrix( 3, 1 );
float y = someMatrix( 4, 1 ); // 4 should be outside the array in a 4x4 matrix

It's counting from 0, and up to 2 (it's a 3x3 matrix). Actually your indexes are completely wrong ;)
Should be this way for translation:
Code: [Select]
float x = someMatrix(0, 2);
float y = someMatrix(1, 2);
Laurent Gomila - SFML developer

Dolf

  • Newbie
  • *
  • Posts: 5
    • View Profile
The sf::Matrix3 class
« Reply #2 on: December 26, 2009, 04:45:15 pm »
Ah ok thanks, so I guess I'll copy a matrix class from somewhere then.

Anyway, the next question would be: Why isn't there a matrix class? You do have a Vector2 class... Are you planning on adding that at any point?

About the indices, ye that was an awfull mistake  :oops:

--
Dolf

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
The sf::Matrix3 class
« Reply #3 on: December 26, 2009, 06:06:44 pm »
Quote
Anyway, the next question would be: Why isn't there a matrix class?

For what? SFML aims at being simple, thus all matrix operations are hidden behind simpler concepts.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
The sf::Matrix3 class
« Reply #4 on: December 27, 2009, 01:24:37 am »
Even in OpenGL, you normally use functions like glTranslatef() or glRotatef() to modify transformation matrices. SFML deals with the same abstraction.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything