示例#1
0
        /// <summary>
        /// generates a 3x3 translate transformation matrix
        /// 1 0 0<para />
        /// 0 1 0<para />
        /// tx ty 1
        /// </summary>
        /// <param name="tx"></param>
        /// <param name="ty"></param>
        internal static DmtxMatrix3 Translate(double tx, double ty)
        {
            DmtxMatrix3 result = new DmtxMatrix3 {
                _data = new[, ] {
                    { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { tx, ty, 1.0 }
                }
            };

            return(result);
        }
示例#2
0
        /// <summary>
        /// generates a 3x3 shear transformation matrix
        /// 0 shx 0<para />
        /// shy 0 0<para />
        /// 0 0 1
        /// </summary>
        /// <returns></returns>
        internal static DmtxMatrix3 Shear(double shx, double shy)
        {
            DmtxMatrix3 result = new DmtxMatrix3 {
                _data = new[, ] {
                    { 1.0, shy, 0.0 }, { shx, 1.0, 0.0 }, { 0, 0, 1.0 }
                }
            };

            return(result);
        }
示例#3
0
        /// <summary>
        /// generates a 3x3 scale transformation matrix
        /// sx 0 0<para />
        /// 0 sy 0<para />
        /// 0 0 1
        /// </summary>
        /// <param name="sx"></param>
        /// <param name="sy"></param>
        /// <returns></returns>
        internal static DmtxMatrix3 Scale(double sx, double sy)
        {
            DmtxMatrix3 result = new DmtxMatrix3 {
                _data = new[, ] {
                    { sx, 0.0, 0.0 }, { 0.0, sy, 0.0 }, { 0, 0, 1.0 }
                }
            };

            return(result);
        }
示例#4
0
        /// <summary>
        /// generates a 3x3 rotate transformation matrix
        /// cos(angle) sin(angle) 0<para />
        /// -sin(angle) cos(angle) 0<para />
        /// 0 0 1
        /// </summary>
        /// <param name="angle"></param>
        internal static DmtxMatrix3 Rotate(double angle)
        {
            DmtxMatrix3 result = new DmtxMatrix3 {
                _data = new[, ] {
                    { Math.Cos(angle), Math.Sin(angle), 0.0 },
                    { -Math.Sin(angle), Math.Cos(angle), 0.0 }, { 0, 0, 1.0 }
                }
            };

            return(result);
        }
        internal static double RightAngleTrueness(DmtxVector2 c0, DmtxVector2 c1, DmtxVector2 c2, double angle)
        {
            DmtxVector2 vA = (c0 - c1);
            DmtxVector2 vB = (c2 - c1);

            vA.Norm();
            vB.Norm();

            DmtxMatrix3 m = DmtxMatrix3.Rotate(angle);

            vB *= m;

            return(vA.Dot(vB));
        }
示例#6
0
        /// <summary>
        /// generates a 3x3 side line skew transformation matrix (inverse)
        /// b0/sz 0 0<para />
        /// 0 b0/b1 (b0 - b1) / (sz * b1)<para />
        /// 0 0 1
        /// </summary>
        /// <returns></returns>
        internal static DmtxMatrix3 LineSkewSideInv(double b0, double b1, double sz)
        {
            if (b1 < DmtxConstants.DmtxAlmostZero)
            {
                throw new ArgumentException("b1 must be larger than zero in top line skew transformation (inverse)");
            }
            DmtxMatrix3 result = new DmtxMatrix3
            {
                _data = new[, ] {
                    { b0 / sz, 0.0, 0.0 }, { 0.0, b0 / b1, (b0 - b1) / (sz * b1) }, { 0, 0, 1.0 }
                }
            };

            return(result);
        }
示例#7
0
        /// <summary>
        /// generates a 3x3 side line skew transformation matrix (inverse)
        /// sz/b0 0 0<para />
        /// 0 b1/b0 (b1-b0)/(sz*b0)<para />
        /// 0 0 1
        /// </summary>
        /// <returns></returns>
        internal static DmtxMatrix3 LineSkewSide(double b0, double b1, double sz)
        {
            if (b0 < DmtxConstants.DmtxAlmostZero)
            {
                throw new ArgumentException("b0 must be larger than zero in side line skew transformation (inverse)");
            }
            DmtxMatrix3 result = new DmtxMatrix3
            {
                _data = new[, ] {
                    { sz / b0, 0.0, 0.0 }, { 0.0, b1 / b0, (b1 - b0) / (sz * b0) }, { 0, 0, 1.0 }
                }
            };

            return(result);
        }
示例#8
0
        public static DmtxMatrix3 operator *(DmtxMatrix3 m1, DmtxMatrix3 m2)
        {
            DmtxMatrix3 result = new DmtxMatrix3 {
                _data = new[, ] {
                    { 0.0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }
                }
            };

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        result[i, j] += m1[i, k] * m2[k, j];
                    }
                }
            }
            return(result);
        }
示例#9
0
 /// <summary>
 /// copy constructor
 /// </summary>
 /// <param name="src">the matrix to copy</param>
 internal DmtxMatrix3(DmtxMatrix3 src)
 {
     _data = new[, ] {
         { src[0, 0], src[0, 1], src[0, 2] }, { src[1, 0], src[1, 1], src[1, 2] }, { src[2, 0], src[2, 1], src[2, 2] }
     };
 }