Пример #1
0
 //-------------------------------------- Quadrilateral transformations
 // The arguments are double[8] that are mapped to quadrilaterals:
 // x1,y1, x2,y2, x3,y3, x4,y4
 public bool QuadToQuad(double[] qs, double[] qd)
 {
     Perspective p = new Perspective();
     if (!QuadToSquare(qs)) return false;
     if (!p.SquareToQuad(qd)) return false;
     Multiply(p);
     return true;
 }
Пример #2
0
 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;
     Perspective t=new Perspective(this);
     t *= Affine.NewRotation(-Rotation());
     t.Transform(ref x1, ref y1);
     t.Transform(ref x2, ref y2);
     x = x2 - x1;
     y = y2 - y1;
 }
Пример #3
0
 //------------------------------------------------------------------------
 public Perspective PreMultiplyInverse(Perspective m)
 {
     Perspective t = m;
     t.Invert();
     Set(t.Multiply(this));
     return this;
 }
Пример #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
 // From trans_perspective
 public Perspective(Perspective a)
 {
     sx  = (a.sx); shy = (a.shy); w0 = a.w0;
     shx = (a.shx); sy = (a.sy); w1 = a.w1;
     tx  = (a.tx); ty = (a.ty); w2 = a.w2;
 }
Пример #6
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;
 }
Пример #7
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;
 }
Пример #8
0
 // From trans_perspective
 public Perspective(Perspective a)
 {
     sx = (a.sx); shy = (a.shy); w0 = a.w0;
     shx = (a.shx); sy = (a.sy); w1 = a.w1;
     tx = (a.tx); ty = (a.ty); w2 = a.w2;
 }
Пример #9
0
 public bool IsEqual(Perspective m)
 {
     return IsEqual(m, affine_epsilon);
 }
Пример #10
0
 public bool IsEqual(Perspective m, double epsilon)
 {
     return Basics.IsEqualEps(sx, m.sx, epsilon) &&
            Basics.IsEqualEps(shy, m.shy, epsilon) &&
            Basics.IsEqualEps(w0, m.w0, epsilon) &&
            Basics.IsEqualEps(shx, m.shx, epsilon) &&
            Basics.IsEqualEps(sy, m.sy, epsilon) &&
            Basics.IsEqualEps(w1, m.w1, epsilon) &&
            Basics.IsEqualEps(tx, m.tx, epsilon) &&
            Basics.IsEqualEps(ty, m.ty, epsilon) &&
            Basics.IsEqualEps(w2, m.w2, epsilon);
 }
Пример #11
0
 // Invert matrix. Returns false in degenerate case
 public bool Invert()
 {
     double d0 = sy * w2 - w1 * ty;
     double d1 = w0 * ty - shy * w2;
     double d2 = shy * w1 - w0 * sy;
     double d = sx * d0 + shx * d1 + tx * d2;
     if (d == 0.0)
     {
         sx = shy = w0 = shx = sy = w1 = tx = ty = w2 = 0.0;
         return false;
     }
     d = 1.0 / d;
     Perspective a = new Perspective(this);
     sx = d * d0;
     shy = d * d1;
     w0 = d * d2;
     shx = d * (a.w1 * a.tx - a.shx * a.w2);
     sy = d * (a.sx * a.w2 - a.w0 * a.tx);
     w1 = d * (a.w0 * a.shx - a.sx * a.w1);
     tx = d * (a.shx * a.ty - a.sy * a.tx);
     ty = d * (a.shy * a.tx - a.sx * a.ty);
     w2 = d * (a.sx * a.sy - a.shy * a.shx);
     return true;
 }
Пример #12
0
 // Inverse transformation of x and y. It works slow because
 // it explicitly inverts the matrix on every call. For massive
 // operations it's better to Invert() the matrix and then use
 // direct transformations.
 public void InverseTransform(ref double x, ref double y)
 {
     Perspective t = new Perspective(this);
     if(t.Invert()) t.Transform(ref x, ref y);
 }
 //--------------------------------------------------------------------
 public PerspectiveLerpSpanInterpolator()
 {
     m_trans_dir = new Transform.Perspective();
     m_trans_inv = new Transform.Perspective();
 }
Пример #14
0
 public void Set(Perspective Other)
 {
     sx = Other.sx;
     shy = Other.shy;
     w0 = Other.w0;
     shx = Other.shx;
     sy = Other.sy;
     w1 = Other.w1;
     tx = Other.tx;
     ty = Other.ty;
     w2 = Other.w2;
 }
Пример #15
0
 //------------------------------------------------------------------------
 public Perspective MultiplyInverse(Perspective m)
 {
     Perspective t = m;
     t.Invert();
     return Multiply(t);
 }
Пример #16
0
 public IteratorX(double px, double py, double step, Perspective m)
 {
     den=(px * m.w0 + py * m.w1 + m.w2);
     den_step=(m.w0 * step);
     nom_x=(px * m.sx + py * m.shx + m.tx);
     nom_x_step=(step * m.sx);
     nom_y=(px * m.shy + py * m.sy + m.ty);
     nom_y_step=(step * m.shy);
     x=(nom_x / den);
     y=(nom_y / den);
 }
Пример #17
0
 //------------------------------------------------------------------------
 public Perspective PreMultiply(Perspective b)
 {
     Perspective a = 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;
     w0  = a.w0 *b.sx  + a.w1 *b.shy + a.w2*b.w0;
     w1  = a.w0 *b.shx + a.w1 *b.sy  + a.w2*b.w1;
     w2  = a.w0 *b.tx  + a.w1 *b.ty  + a.w2*b.w2;
     return this;
 }
 //--------------------------------------------------------------------
 public PerspectiveLerpSpanInterpolator()
 {
     m_trans_dir = new Transform.Perspective();
     m_trans_inv = new Transform.Perspective();
 }
Пример #19
0
 public bool IsEqual(Perspective m)
 {
     return(IsEqual(m, affine_epsilon));
 }