Thursday, 3 April 2014

Shearing | Sheared transformation




A transformation that slants the shape of an object is called sheared transformation. Two common shearing are:
  •  X-shear 
  • Y – shear
 
X- shear: In this y co-ordinate will preserve their value but the x-coordinate changes its value which causes vertical lines to tilled , right or left.


Y- shear: In this x co-ordinate will preserve their value but the y-coordinate changes its value which causes vertical lines to tilled, right or left.
 

                                                 

  • It is more efficient than cohen and sutherland line algorithm liang barsky.
  •  liang barsky has developed the algorithm using the parametric equation are:
x= x1+TX
y= y1+TY
                                                         where X= x1-x2, Y= y1-y
  •  The point clipping condition for liang barsky are:
                         xw min <= x1+TX <= xw max
                         yw min <= y1+TY <=yw max
  • Liang barsky express these four with two parameter p and q as t pi<qi where i=1,2,3.......
             where the parameter p and q are :
              p1 = -X , p2 = X , p3= -Y , p4 = Y and q1 = x1-xw min , q2= xw max- x1 , q3= y1-yw min ,              q4= yw max - y1
  •  If pi= 0 then line is parallel to  i th boundary where i=1,2,3......
  •  If qi= 0 then line is completely outside the boundary so we can discard the line.
  • The non zero value of pi the line cross the clipping boundary and we have to find the parameter 't'. where t= qi/pi
  •  this algorithm find the two value of 't' such as 't1' and 't2'.
  • The value of 't1' is taken as the largest value among various values of intersection with all edges i.e; pi < 0. and The value of 't2' is taken as the smallest value i.e; pi > 0.
  •  if (t1<t2) then some formulas are used to find the ends points .
  1.   xx1= x1+t1X
  2.   xx2= x1+ t2X
  3.  yy1= y1+ t1Y
  4.  yy2 = y2+t2Y (Then draw the line)
  • STOP 


  

ADVANTAGES OF LIANG BARSKY ALGORITHM
  1.  It is more efficient then sutherland and cohen algorithm because intersection calculation are reduce.
  2. It required only one division to update parameter p1 and p2.
  3. Window intersection of the lines are computed only once.