示例#1
0
文件: Affine.cs 项目: Kintaro/Pictor
 /// <summary>
 /// 
 /// </summary>
 /// <param name="copyFrom">
 /// A <see cref="Affine"/>
 /// </param>
 public Affine(Affine copyFrom)
 {
     sx = copyFrom.sx;
     shy = copyFrom.shy;
     shx = copyFrom.shx;
     sy = copyFrom.sy;
     tx = copyFrom.tx;
     ty = copyFrom.ty;
 }
示例#2
0
 //------------------------------------------------------------------------
 public Perspective TransPerspectiveMultiplyInverse(Affine m)
 {
     Affine t = m;
     t.Invert();
     return Multiply(t);
 }
示例#3
0
 // From affine
 public Perspective(Affine a)
 {
     sx = (a.sx); shy = (a.shy); w0 = (0);
     shx = (a.shx); sy = (a.sy); w1 = (0);
     tx = (a.tx); ty = (a.ty); w2 = (1);
 }
示例#4
0
 // Multiply inverse of "m" by "this" and assign the result to "this"
 public Perspective PreMultiplyInverse(Affine m)
 {
     Perspective t=new Perspective(m);
     t.Invert();
     Set(t.Multiply(this));
     return this;
 }
示例#5
0
 //------------------------------------------------------------------------
 public Perspective PreMultiply(Affine b)
 {
     Perspective a = new Perspective(this);
     sx  = a.sx *b.sx  + a.shx*b.shy;
     shx = a.sx *b.shx + a.shx*b.sy;
     tx  = a.sx *b.tx  + a.shx*b.ty  + a.tx;
     shy = a.shy*b.sx  + a.sy *b.shy;
     sy  = a.shy*b.shx + a.sy *b.sy;
     ty  = a.shy*b.tx  + a.sy *b.ty  + a.ty;
     w0  = a.w0 *b.sx  + a.w1 *b.shy;
     w1  = a.w0 *b.shx + a.w1 *b.sy;
     w2  = a.w0 *b.tx  + a.w1 *b.ty  + a.w2;
     return this;
 }
示例#6
0
 //------------------------------------------------------------------------
 public Perspective Multiply(Affine a)
 {
     Perspective b = new Perspective(this);
     sx  = a.sx *b.sx  + a.shx*b.shy + a.tx*b.w0;
     shx = a.sx *b.shx + a.shx*b.sy  + a.tx*b.w1;
     tx  = a.sx *b.tx  + a.shx*b.ty  + a.tx*b.w2;
     shy = a.shy*b.sx  + a.sy *b.shy + a.ty*b.w0;
     sy  = a.shy*b.shx + a.sy *b.sy  + a.ty*b.w1;
     ty  = a.shy*b.tx  + a.sy *b.ty  + a.ty*b.w2;
     return this;
 }
示例#7
0
 //--------------------------------------------------------- Operations
 public Perspective FromAffine(Affine a)
 {
     sx  = a.sx;  shy = a.shy; w0 = 0;
     shx = a.shx; sy  = a.sy;  w1 = 0;
     tx  = a.tx;  ty  = a.ty;  w2 = 1;
     return this;
 }
示例#8
0
 public void SetTransform(Affine value)
 {
     m_Transform = value;
 }
示例#9
0
 // Multiply matrix to another one
 void Multiply(Affine m)
 {
     double t0 = sx  * m.sx + shy * m.shx;
     double t2 = shx * m.sx + sy  * m.shx;
     double t4 = tx  * m.sx + ty  * m.shx + m.tx;
     shy = sx  * m.shy + shy * m.sy;
     sy  = shx * m.shy + sy  * m.sy;
     ty  = tx  * m.shy + ty  * m.sy + m.ty;
     sx  = t0;
     shx = t2;
     tx  = t4;
 }
示例#10
0
 ///<summary>
 ///</summary>
 ///<param name="x"></param>
 ///<param name="y"></param>
 public void Scaling(out double x, out double y)
 {
     double x1 = 0.0;
     double y1 = 0.0;
     double x2 = 1.0;
     double y2 = 1.0;
     Affine t = new Affine(this);
     t *= NewRotation(-Rotation());
     t.Transform(ref x1, ref y1);
     t.Transform(ref x2, ref y2);
     x = x2 - x1;
     y = y2 - y1;
 }
示例#11
0
 ///<summary>
 ///</summary>
 ///<param name="m"></param>
 ///<param name="epsilon"></param>
 ///<returns></returns>
 public bool IsEqual(Affine m, double epsilon)
 {
     return Basics.IsEqualEps(sx, m.sx, epsilon) &&
         Basics.IsEqualEps(shy, m.shy, epsilon) &&
         Basics.IsEqualEps(shx, m.shx, epsilon) &&
         Basics.IsEqualEps(sy, m.sy, epsilon) &&
         Basics.IsEqualEps(tx, m.tx, epsilon) &&
         Basics.IsEqualEps(ty, m.ty, epsilon);
 }
示例#12
0
        ///<summary>
        ///</summary>
        ///<returns></returns>
        public static Affine NewIdentity()
        {
            Affine newAffine = new Affine {sx = 1.0, shy = 0.0, shx = 0.0, sy = 1.0, tx = 0.0, ty = 0.0};

            return newAffine;
        }
示例#13
0
 ///<summary>
 ///</summary>
 ///<param name="a"></param>
 ///<param name="b"></param>
 ///<returns></returns>
 public static Affine operator *(Affine a, Affine b)
 {
     Affine temp = new Affine(a);
     temp.Multiply(b);
     return temp;
 }
示例#14
0
文件: Affine.cs 项目: Kintaro/Pictor
        /// <summary>
        /// 
        /// </summary>
        /// <returns>
        /// A <see cref="Affine"/>
        /// </returns>
        public static Affine NewIdentity()
        {
            Affine newAffine = new Affine ();
            newAffine.sx = 1.0;
            newAffine.shy = 0.0;
            newAffine.shx = 0.0;
            newAffine.sy = 1.0;
            newAffine.tx = 0.0;
            newAffine.ty = 0.0;

            return newAffine;
        }
示例#15
0
        ///<summary>
        ///</summary>
        ///<returns></returns>
        public static Affine NewIdentity()
        {
            Affine newAffine = new Affine(1.0, 0.0, 0.0, 1.0, 0.0, 0.0);

            return newAffine;
        }
示例#16
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="value">
 /// A <see cref="Affine"/>
 /// </param>
 public void SetTransform(Affine value)
 {
     affineTransformStack.Pop ();
     affineTransformStack.Push (value);
 }