Ejemplo n.º 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();

            result._data = new double[3, 3] {
                { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { tx, ty, 1.0 }
            };
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// generates a 3x3 shear transformation matrix
        /// 0 shx 0<para />
        /// shy 0 0<para />
        /// 0 0 1
        /// </summary>
        /// <param name="sx"></param>
        /// <param name="sy"></param>
        /// <returns></returns>
        internal static DmtxMatrix3 Shear(double shx, double shy)
        {
            DmtxMatrix3 result = new DmtxMatrix3();

            result._data = new double[3, 3] {
                { 1.0, shy, 0.0 }, { shx, 1.0, 0.0 }, { 0, 0, 1.0 }
            };
            return(result);
        }
Ejemplo n.º 3
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();

            result._data = new double[3, 3] {
                { Math.Cos(angle), Math.Sin(angle), 0.0 }, { -Math.Sin(angle), Math.Cos(angle), 0.0 }, { 0, 0, 1.0 }
            };
            return(result);
        }
Ejemplo n.º 4
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();

            result._data = new double[3, 3] {
                { sx, 0.0, 0.0 }, { 0.0, sy, 0.0 }, { 0, 0, 1.0 }
            };
            return(result);
        }
Ejemplo n.º 5
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>
        /// <param name="sx"></param>
        /// <param name="sy"></param>
        /// <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();

            result._data = new double[3, 3] {
                { b0 / sz, 0.0, 0.0 }, { 0.0, b0 / b1, (b0 - b1) / (sz * b1) }, { 0, 0, 1.0 }
            };
            return(result);
        }
Ejemplo n.º 6
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>
        /// <param name="sx"></param>
        /// <param name="sy"></param>
        /// <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();

            result._data = new double[3, 3] {
                { sz / b0, 0.0, 0.0 }, { 0.0, b1 / b0, (b1 - b0) / (sz * b0) }, { 0, 0, 1.0 }
            };
            return(result);
        }
Ejemplo n.º 7
0
        internal static double RightAngleTrueness(DmtxVector2 c0, DmtxVector2 c1, DmtxVector2 c2, double angle)
        {
            DmtxVector2 vA, vB;


            vA = (c0 - c1);
            vB = (c2 - c1);
            vA.Norm();
            vB.Norm();

            DmtxMatrix3 m = DmtxMatrix3.Rotate(angle);

            vB *= m;

            return(vA.Dot(vB));
        }
Ejemplo n.º 8
0
        public static DmtxMatrix3 operator *(DmtxMatrix3 m1, DmtxMatrix3 m2)
        {
            DmtxMatrix3 result = new DmtxMatrix3();
            result._data = new double[3, 3] { { 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;
        }
Ejemplo n.º 9
0
        public static DmtxMatrix3 operator *(DmtxMatrix3 m1, DmtxMatrix3 m2)
        {
            DmtxMatrix3 result = new DmtxMatrix3();

            result._data = new double[3, 3] {
                { 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);
        }
Ejemplo n.º 10
0
 internal DmtxRegion(DmtxRegion src)
 {
     this._bottomAngle = src._bottomAngle;
     this._bottomKnown = src._bottomKnown;
     this._bottomLine = src._bottomLine;
     this._bottomLoc = src._bottomLoc;
     this._boundMax = src._boundMax;
     this._boundMin = src._boundMin;
     this._finalNeg = src._finalNeg;
     this._finalPos = src._finalPos;
     this._fit2raw = new DmtxMatrix3(src._fit2raw);
     this._flowBegin = src._flowBegin;
     this._jumpToNeg = src._jumpToNeg;
     this._jumpToPos = src._jumpToPos;
     this._leftAngle = src._leftAngle;
     this._leftKnown = src._leftKnown;
     this._leftLine = src._leftLine;
     this._leftLoc = src._leftLoc;
     this._locR = src._locR;
     this._locT = src._locT;
     this._mappingCols = src._mappingCols;
     this._mappingRows = src._mappingRows;
     this._offColor = src._offColor;
     this._onColor = src._onColor;
     this._polarity = src._polarity;
     this._raw2fit = new DmtxMatrix3(src._raw2fit);
     this._rightAngle = src._rightAngle;
     this._rightKnown = src._rightKnown;
     this._rightLoc = src._rightLoc;
     this._sizeIdx = src._sizeIdx;
     this._stepR = src._stepR;
     this._stepsTotal = src._stepsTotal;
     this._stepT = src._stepT;
     this._symbolCols = src._symbolCols;
     this._symbolRows = src._symbolRows;
     this._topAngle = src._topAngle;
     this._topKnown = src._topKnown;
     this._topLoc = src._topLoc;
 }
Ejemplo n.º 11
0
 internal DmtxRegion(DmtxRegion src)
 {
     this._bottomAngle = src._bottomAngle;
     this._bottomKnown = src._bottomKnown;
     this._bottomLine  = src._bottomLine;
     this._bottomLoc   = src._bottomLoc;
     this._boundMax    = src._boundMax;
     this._boundMin    = src._boundMin;
     this._finalNeg    = src._finalNeg;
     this._finalPos    = src._finalPos;
     this._fit2raw     = new DmtxMatrix3(src._fit2raw);
     this._flowBegin   = src._flowBegin;
     this._jumpToNeg   = src._jumpToNeg;
     this._jumpToPos   = src._jumpToPos;
     this._leftAngle   = src._leftAngle;
     this._leftKnown   = src._leftKnown;
     this._leftLine    = src._leftLine;
     this._leftLoc     = src._leftLoc;
     this._locR        = src._locR;
     this._locT        = src._locT;
     this._mappingCols = src._mappingCols;
     this._mappingRows = src._mappingRows;
     this._offColor    = src._offColor;
     this._onColor     = src._onColor;
     this._polarity    = src._polarity;
     this._raw2fit     = new DmtxMatrix3(src._raw2fit);
     this._rightAngle  = src._rightAngle;
     this._rightKnown  = src._rightKnown;
     this._rightLoc    = src._rightLoc;
     this._sizeIdx     = src._sizeIdx;
     this._stepR       = src._stepR;
     this._stepsTotal  = src._stepsTotal;
     this._stepT       = src._stepT;
     this._symbolCols  = src._symbolCols;
     this._symbolRows  = src._symbolRows;
     this._topAngle    = src._topAngle;
     this._topKnown    = src._topKnown;
     this._topLoc      = src._topLoc;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// generates a 3x3 top line skew transformation matrix
 /// b1/b0 0 (b1-b0)/(sz * b0)<para />
 /// 0 sz/b0 0<para />
 /// 0 0 1
 /// </summary>
 /// <param name="sx"></param>
 /// <param name="sy"></param>
 /// <returns></returns>
 internal static DmtxMatrix3 LineSkewTop(double b0, double b1, double sz)
 {
     if (b0 < DmtxConstants.DmtxAlmostZero)
     {
         throw new ArgumentException("b0 must be larger than zero in top line skew transformation");
     }
     DmtxMatrix3 result = new DmtxMatrix3();
     result._data = new double[3, 3] { { b1 / b0, 0.0, (b1 - b0) / (sz * b0) }, { 0.0, sz / b0, 0.0 }, { 0, 0, 1.0 } };
     return result;
 }
Ejemplo n.º 13
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();
     result._data = new double[3, 3] { { Math.Cos(angle), Math.Sin(angle), 0.0 }, { -Math.Sin(angle), Math.Cos(angle), 0.0 }, { 0, 0, 1.0 } };
     return result;
 }
Ejemplo n.º 14
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();
     result._data = new double[3, 3] { { sx, 0.0, 0.0 }, { 0.0, sy, 0.0 }, { 0, 0, 1.0 } };
     return result;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// copy constructor
 /// </summary>
 /// <param name="src">the matrix to copy</param>
 internal DmtxMatrix3(DmtxMatrix3 src)
 {
     _data = new double[3, 3] { { 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] } };
 }
Ejemplo n.º 16
0
 /// <summary>
 /// generates a 3x3 shear transformation matrix
 /// 0 shx 0<para />
 /// shy 0 0<para />
 /// 0 0 1
 /// </summary>
 /// <param name="sx"></param>
 /// <param name="sy"></param>
 /// <returns></returns>
 internal static DmtxMatrix3 Shear(double shx, double shy)
 {
     DmtxMatrix3 result = new DmtxMatrix3();
     result._data = new double[3, 3] { { 1.0, shy, 0.0 }, { shx, 1.0, 0.0 }, { 0, 0, 1.0 } };
     return result;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// copy constructor
 /// </summary>
 /// <param name="src">the matrix to copy</param>
 internal DmtxMatrix3(DmtxMatrix3 src)
 {
     _data = new double[3, 3] {
         { 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] }
     };
 }
Ejemplo n.º 18
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();
     result._data = new double[3, 3] { { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { tx, ty, 1.0 } };
     return result;
 }
Ejemplo n.º 19
0
 /// <summary>
 /// generates a 3x3 top line skew transformation matrix (inverse)
 /// b0/b1 0 (b0-b1)/(sz * b1)<para />
 /// 0 b0/sz 0<para />
 /// 0 0 1
 /// </summary>
 /// <param name="sx"></param>
 /// <param name="sy"></param>
 /// <returns></returns>
 internal static DmtxMatrix3 LineSkewTopInv(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();
     result._data = new double[3, 3] { { b0 / b1, 0.0, (b0 - b1) / (sz * b1) }, { 0.0, b0 / sz, 0.0 }, { 0, 0, 1.0 } };
     return result;
 }