1212
1313from Plotting import PlotWidget #The plot object
1414
15- """Transformation matrix"""
16- transformationMatrix = Matrix ([[1 , 0 , 0 ],
17- [0 , 0.5 , 0 ],
18- [0 , 0 , 1 ]])
19-
2015def transformPoint (x ,y ,z ):
2116 """Return the vector transformed
2217
@@ -51,28 +46,51 @@ def get_grid(min,max):
5146 xyzgrid = column_stack ([[x , y ,z ] for x in xvals for y in yvals for z in zvals ])
5247 return xyzgrid
5348
54- if __name__ == "__main__" :
49+ def get_transformedGrid (originalGrid , transformationMatrix ):
50+ """Return a grid in x, y and z transformed
51+
52+ ...
5553
56- originalGrid = get_grid (- 2 ,2 )
54+ Parameters
55+ ----------
56+ originalGrid
57+
58+ transformationMatrix
59+
60+ """
5761 transformedGrid = transformPoint (originalGrid [0 ],originalGrid [1 ],originalGrid [2 ])
58- xyzgrid = array ([transformedGrid [0 ,:][0 ,:], #
59- transformedGrid [1 ,:][0 ,:], # Save the transformed grid as a numpy array
60- transformedGrid [2 ,:][0 ,:]]) #
62+ return array ([transformedGrid [0 ,:][0 ,:], #
63+ transformedGrid [1 ,:][0 ,:], # Save the transformed grid as a numpy array
64+ transformedGrid [2 ,:][0 ,:]]) #
65+
66+ def adjust_plot (axes ):
67+ axes .set_xlim ([- 2 , 2 ]) #
68+ axes .set_ylim ([- 2 , 2 ]) # Set the limits of the plot
69+ axes .set_zlim ([- 2 , 2 ]) #
70+ axes .axis ('on' ) # Show the axis
71+ axes .set_xlabel ('x' ) #
72+ axes .set_ylabel ('y' ) # Axes names
73+ axes .set_zlabel ('z' ) #
74+ axes .grid (False ) # Don't show the grid
75+ axes .view_init (10 ,5 ) # View init at 15 and 5 degrees
76+
77+ if __name__ == "__main__" :
78+ """Transformation matrix"""
79+ transformationMatrix = Matrix ([[1 , 0 , 0 ],
80+ [0 , 1 , 0 ],
81+ [0 , 1 , 1 ]])
82+
83+ originalGrid = get_grid (- 2 ,2 ) # Create a straigh grid
84+ xyzgrid = get_transformedGrid (originalGrid , transformationMatrix ) # get a transformed grid
6185
6286 colors = list (map (colorizer , originalGrid [0 ], originalGrid [1 ], originalGrid [2 ])) # Asign the colors to the points
6387
6488 app = QtWidgets .QApplication ([])
65- plot = PlotWidget (xyzgrid [0 ], xyzgrid [1 ], xyzgrid [2 ], colors = colors , alpha = 0.7 )
66-
67- plot .axes .set_xlim ([- 2 , 2 ]) #
68- plot .axes .set_ylim ([- 2 , 2 ]) # Set the limits of the plot
69- plot .axes .set_zlim ([- 2 , 2 ]) #
70- plot .axes .axis ('on' ) # Show the axis
71- plot .axes .set_xlabel ('x' ) #
72- plot .axes .set_ylabel ('y' ) # Axes names
73- plot .axes .set_zlabel ('z' ) #
74- plot .axes .grid (False ) # Don't show the grid
75- plot .axes .view_init (10 ,5 ) # View init at 15 and 5 degrees
89+ plot = PlotWidget ()
90+
91+ plot .scatter (xyzgrid ,colors )
92+
93+ adjust_plot (plot .axes )
7694
7795 plot .show ()
7896 app .exec ()
0 commit comments