[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

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

Faustino Dina

11/1/2004 5:13:00 PM

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


1 Answer

Frank Hileman

11/1/2004 5:44:00 PM

0

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