Archived

This topic is now archived and is closed to further replies.

vanillacoke

matrices

Recommended Posts

For those of you who code without the assistance of a graphics API, would you care to help me out a bit with matrices? I''m wondering how people usually implement matrices in their systems. I have a 4x4 matrix struct, and overloaded + and * operators right now. I think it works as I need it to, but I''m wondering how others have done it.

Share this post


Link to post
Share on other sites
I don''t know what you really want, but I designed my matrix class to work with DirectX, but I suspect you could talor it to mix with others as well. This is what I am currently using...

void scale( double a );
void scale( double sx= 1, double sy= 1, double sz= 1, double sw= 1 );
void rotate( double x, double y, double z );
void translate( double x, double y, double z );
void perspective( double v, double h, double near, double far );
void perspectiveFov( double fov, double aspect, double zn, double zf );
void perspectivePrism( double xmin, double xmax, double ymin, double ymax, double zn, double zf );
void viewport( Vector eye, Vector at, Vector up );
void ortho( double w, double h, double zn, double zf );
void orthoPrism( double xmin, double xmax, double ymin, double ymax, double zn, double zf );
Matrix identity( void );
Matrix inverse( void );

Matrix operator + (Matrix m);
Matrix operator - (Matrix m);
Matrix operator * (Matrix m);

This is for no reason all that you would need.

Share this post


Link to post
Share on other sites
You can open the D3DX (the helper library) header files at your leasure.

I''ve checked once, and there wasn''t any particular trick. They just did the obvious, but didn''t overload the * operator, because the temporaries created would have slowed down the calculations, I think.

Cédric

Share this post


Link to post
Share on other sites