Concerns on Drawing2D.Matrix.Rotate and Math function mixing...

  • Thread starter Thread starter Faustino Dina
  • Start date Start date
F

Faustino Dina

Hi,

I'm implementing some algebra algorithms in C#, so I think to use the Matrix
class in some operations. But I was struck by two factors:
-The Matrix.Rotate() functions (and in general, all angle operations in
System.Drawing.Drawing2D) are in decimal gradus, but basic angle functions
in Math package are un radians. It is a problem, I should convert my angles
all the time betweem these two systems if I want to use the Matrix class
functions with my own functions.
-The angle used by Matrix.Rotate() increases clockwise. But as long as I
understand in "normal" mathematics the angle increases the reverse. The Math
functions like Math.Sin understand angles increasing non-clockwise. So if I
want to use Matrix.Rotate I should also convert my angles to this "reversed"
coordinate system.

These are my concerns. Am I right? System.Drawing.Drawing2D and Math
packages doesn't mix? Which is the reccommended practice in this situation?
To use another "right" Matrix package? Which one do you reccomend?

Thanks in advance
Faustino
 
Hello Faustino,

I don't recommend the System.Drawing.Drawing2D Matrix class for anything
except creating transformations for Graphics objects. It is inefficient, and
a class instead of a value type, making it clumsy as well. You are better
off using a custom Matrix struct.
-The angle used by Matrix.Rotate() increases clockwise. But as long as I
understand in "normal" mathematics the angle increases the reverse. The
Math
functions like Math.Sin understand angles increasing non-clockwise. So if
I
want to use Matrix.Rotate I should also convert my angles to this
"reversed"
coordinate system.

It is reversed only if the y coordinates go down instead of up.

There are other matrix classes out there. You may wish to look on
codeproject. If you need a GDI+ specific Matrix struct for 2d graphics, that
is lighter and faster than System.Drawing.Drawing2D.Matrix,
there is one in the free VG.net runtime called FMatrix. This one also uses
degree angles.

Regards,
Frank Hileman

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
 
Back
Top