Re: Matrix - Transformation

by Thomas Bauer on 11/1/2007 3:42:00 AM Hello Peter,
you are angry with me, correct?
I did not want that. Well, I wanted only to show the problem
definition.
In completely form.
It say ud simply can whether you still help or not?
Can you say simply whether you still help or not?
I know the transformation is complicated, nevertheless it would be
nicely for tip
or you can recommend a good book
     - Matrix
     -Transformation
in C#
I must solve simply the problem, it is important for me.

Thanks and have a nice day / evening.

Regards Thomas

 

Re: Matrix - Transformation

by Peter Duniho on 11/1/2007 4:01:00 AM On 2007-11-01 10:42:15 -0700, Thomas Bauer <mail3232@arcor.de> said:

> Hello Peter,
> you are angry with me, correct?

I am not angry. I've simply recognized that I do not have the skills
necessary to help you resolve your question. I am not interested in
repeating the same thing over and over again, and we have what seems to
me to be an unresolvable communication gap.

Whether this is strictly because of the difference in native languages,
or there is something else going on, I can't say. But not only am I
having difficulty understanding you, you seem to be having difficulty
understanding me. I've posted a number of messages that should have
answered the question as I understand it, but you keep posting new
messages that don't seem at all relevant to the solution I've offered.

You really should just find someone who speaks a language in which
you're fluent (German?) who has the knowledge to help you. If I
understand your problem correctly, it's not really that hard, so it's
not at all true that I'm the only person around who could answer the
question.

There are language-specific newsgroups for a variety of Microsoft
technologies, and I believe that includes C# and .NET. Have you tried
one of those?

I'm sorry I couldn't be of more help. But the fact is, I believe I
can't be. There's not any point in me trying to be.

Pete

 

Re: Matrix - Transformation

by Thomas Bauer on 11/2/2007 7:11:00 PM Hello Pete,
is ok, I try my last question.
Maybe you help me. It is your decision.

I have problems from mm to pixel.
            float scaleX =3D (float)panel_draw.DisplayRectangle.Width /
Math.Abs(fWidth);
            float scaleY =3D (float)panel_draw.DisplayRectangle.Height /
Math.Abs(fHeight);
Here is a mistake.

The user coordinates are 0,0,900,500 in mm
I want to draw it inside the windows panel panel_draw. Not more.

I prefer the zero point like this.
 case Origin.BottomRight:
                    {
                        Matrix m =3D new Matrix();
                        m.Translate(fWidth - 1, fHeight - 1);
                        m.Scale(-1, -1);
                        e.Graphics.Transform =3D m;
                        break;
                    }
It is good for overview.


In appendix the project.

Regards Thomas



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace ucProductlistView
{
    public partial class ucProductlistView : UserControl
    {
//
***************************************************************************=
**
        public enum Origin
        {
            TopLeft,
            TopRight,
            BottomLeft,
            BottomRight
        }
        //-----------------------------------------------------------------=
---------
        const float fX =3D 0;
        const float fY =3D 0;
        const float fWidth =3D 900;
        const float fHeight =3D 500;


        #region Punkte Liste
            public List<Codes> listCodes;

            /// <summary>Die Farbe, mit der die Buchstaben
            /// neben dem Kreuz gezeichnet werden</summary>
            Brush brush;

            int anzX =3D 4;
            int anzY =3D 5;
            int abstandX =3D 50;
            int abstandY =3D 30;

            /// <summary>Radius des Kreuzes</summary>
            int kRad =3D 5;

            /// <summary>X-Abstand der Buchstaben vom Punkt</summary>
            int xPunktAbstand =3D 10;

            /// <summary>Skalierung der gesamten Grafik. 1=3Dnicht
skaliert.</summary>
            float gesamtSkalierung =3D 1;

            float fontGr=F6ssePunktBeschreibung =3D 6.0F;
            Font punktBeschreibungsFont;

            public class Codes
            {
                private double x;
                private double y;
                private int boardNumber;

                public double X
                {
                    get { return x; }
                    set { x =3D value; }
                }

                public double Y
                {
                    get { return y; }
                    set { y =3D value; }
                }

                public PointF GetPointF()
                {
                    return new PointF((float)x, (float)y);
                }

                public int BoardNumber
                {
                    get { return boardNumber; }
                    set { boardNumber =3D value; }
                }

                public Codes(double x, double y, int boardNumber)
                {
                    this.x =3D x;
                    this.y =3D y;
                    this.boardNumber =3D boardNumber;
                }
            }
        #endregion

        Origin _origin =3D Origin.TopLeft;

        public ucProductlistView()
        {
            InitializeComponent();

            ListCodesF=FCllen(ref listCodes, anzX, anzY, abstandX,
abstandY);
            //brush =3D new SolidBrush(this.ForeColor);
            brush =3D new SolidBrush(Color.Red);

            punktBeschreibungsFont =3D new Font("Arial",
fontGr=F6ssePunktBeschreibung);
        }

        private void ListCodesF=FCllen(ref List<Codes> listCodes, int
anzX, int anzY, int abstandX, int abstandY)
        {
            listCodes =3D new List<Codes>();
            Codes codes;
            int boardNumber =3D 0;

            for (int x =3D 0; x < anzX; x++)
            {
                for (int y =3D 0; y < anzY; y++)
                {
                    boardNumber++;
                    codes =3D new Codes(x * abstandX, y * abstandY,
boardNumber);
                    listCodes.Add(codes);
                }
            }
        }

        float zollAlsMillimeter =3D 25.4F;

        PointF MillimeterToPixelPointF(Graphics g, PointF p)
        {
            p.X *=3D g.DpiX / zollAlsMillimeter;
            p.Y *=3D g.DpiY / zollAlsMillimeter;
            return p;
        }

        private void panel_draw_Paint(object sender, PaintEventArgs e)
        {
            _origin =3D Origin.TopRight;

            base.OnPaint(e);

            Graphics g =3D e.Graphics;
            PointF ptCur;
            string strPoint;
            // momentan keine Auswirkung
            g.ScaleTransform(gesamtSkalierung, gesamtSkalierung);

            ptCur =3D new PointF();
            foreach (Codes code in listCodes)
            {
                ptCur =3D MillimeterToPixelPointF(g, code.GetPointF());

                // Zeichnen der zwei Linien, die das Kreuz bilden
                g.DrawLine(Pens.Black, ptCur.X - kRad, ptCur.Y,
ptCur.X + kRad, ptCur.Y);
                g.DrawLine(Pens.Black, ptCur.X, ptCur.Y - kRad,
ptCur.X, ptCur.Y + kRad);

                // Buchstaben und Bezeichnungen f=FCr den Punkt zeichnen
                strPoint =3D "P" + code.BoardNumber + "(" + code.X + ","
+ code.Y + ")";
                //g.DrawString(strPoint, Font, brush, ptCur.X +
xPunktAbstand, ptCur.Y);
                g.DrawString(strPoint, punktBeschreibungsFont, brush,
ptCur.X + xPunktAbstand, ptCur.Y);
            }



            float scaleX =3D (float)panel_draw.DisplayRectangle.Width /
Math.Abs(fWidth);
            float scaleY =3D (float)panel_draw.DisplayRectangle.Height /
Math.Abs(fHeight);

            switch (_origin)
            {
                case Origin.TopLeft:
                    {
                        Matrix m =3D new Matrix();
                        m.Translate(0, 0);
                        m.Scale(1, 1);
                        e.Graphics.Transform =3D m;
                        break;
                    }
                case Origin.TopRight:
                    {
                        Matrix m =3D new Matrix();
                        m.Translate(fWidth - 1, 0);
                        //m.Scale(-1, 1);
                        m.Scale(scaleX, scaleY);
                        e.Graphics.Transform =3D m;
                        break;
                    }
                case Origin.BottomLeft:
                    {
                        Matrix m =3D new Matrix();
                        m.Translate(0, fHeight - 1);
                        m.Scale(1, -1);
                        e.Graphics.Transform =3D m;
                        break;
                    }
                case Origin.BottomRight:
                    {
                        Matrix m =3D new Matrix();
                        m.Translate(fWidth - 1, fHeight - 1);
                        m.Scale(-1, -1);
                        e.Graphics.Transform =3D m;
                        break;
                    }
            }

        }
    }
}