213 - A27 - Octave code for Graphical Transformations

29 days ago by Professor213

# This code might create a nicer picture using sagecell.sagemath.org Ashift = [ 1 0 -2;0 1 3;0 0 1] Areflect = [-1 0 0;0 1 0;0 0 1] A = Areflect*Ashift pts = [0 0 1;2 4 1;-4 6 1;-5 -2 1]'; # these have been entered transposed to make entering new points easier. new = A*pts; n = size(pts)(2); # this is the number of points that are being transformed...the number of columns of pts axis([-10,10,-10,10]) hold on plot(pts(1,1:n),pts(2,1:n),'r') # x-values are in the first row and y-values are in the second row plot(new(1,1:n),new(2,1:n),'b') 
       
Ashift =

 1 0 -2
 0 1 3
 0 0 1

Areflect =

 -1 0 0
 0 1 0
 0 0 1

A =

 -1 0 2
 0 1 3
 0 0 1

                                                                        

  10 |-+                                                                

     |                                                  ######          

     |                                        ##########      #         

     |                                  ######                #         

     |                    ******         ##                    #        

   5 |-+                  *     ********** ##                  #        

     |                    *               ***##*                #       

     |                    *                  **#                #       

     |                   *                 **                    #      

     |                   *               **                      #      

   0 |-+                 *              *                               

     |                  *                                               

     |                 *                                                

     |                                                                  

     |                                                                  

  -5 |-+                                                                

     |                                                                  

     |                                                                  

     |                                                                  

     |                 +                +                 +             
+   
 -10
|---------------------------------------------------------------------- 

    -10               -5                0                 5             
10   
                                                                        
Ashift =

 1 0 -2
 0 1 3
 0 0 1

Areflect =

 -1 0 0
 0 1 0
 0 0 1

A =

 -1 0 2
 0 1 3
 0 0 1

                                                                               
  10 |-+                                                                       
     |                                                  ######                 
     |                                        ##########      #                
     |                                  ######                #                
     |                    ******         ##                    #               
   5 |-+                  *     ********** ##                  #               
     |                    *               ***##*                #              
     |                    *                  **#                #              
     |                   *                 **                    #             
     |                   *               **                      #             
   0 |-+                 *              *                                      
     |                  *                                                      
     |                 *                                                       
     |                                                                         
     |                                                                         
  -5 |-+                                                                       
     |                                                                         
     |                                                                         
     |                                                                         
     |                 +                +                 +                +   
 -10 |----------------------------------------------------------------------   
    -10               -5                0                 5               10