Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Affine

Thesilverwolf Mar 29th, 2018 72 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import math
  4. import pylab
  5. from mpl_toolkits.mplot3d import Axes3D
  6. import copy
  7.  
  8. myArray = [[-3,2,3],[3,2,3],[1,2,-3],[1,2,-1],[-1,2,-1],[-1,2,-3],[-3,2,3]]
  9. rotateArray = copy.deepcopy(myArray)
  10. resizeArray = copy.deepcopy(myArray)
  11. mirrorArray = copy.deepcopy(myArray)
  12. changeArray = copy.deepcopy(myArray)
  13.  
  14. def getX(getArrayX):
  15.     i = 0
  16.     xarray = []
  17.     while i < len(getArrayX):
  18.         xarray.append(getArrayX[i][0])        
  19.         i=i+1  
  20.     return xarray
  21. def getY(getArrayY):
  22.     i = 0
  23.     xarray = []
  24.     while i < len(getArrayY):
  25.         xarray.append(getArrayY[i][1])        
  26.         i=i+1  
  27.     return xarray
  28. def getZ(getArrayZ):
  29.     i = 0
  30.     zarray = []
  31.     while i < len(getArrayZ):
  32.         zarray.append(getArrayZ[i][2])        
  33.         i=i+1  
  34.     return zarray
  35.  
  36. #Опишем функцию отрисовки
  37. def showPlot(newArray):
  38.     fig = pylab.figure()
  39.     axes = Axes3D(fig)
  40.     axes.plot(getX(newArray),getY(newArray),getZ(newArray))
  41.     pylab.show()
  42.  
  43. #Опишем функцию умножения матриц    
  44. def AxB(fA,sA):
  45.     i = 0
  46.     nA = fA
  47.     while i < len(fA):
  48.         iS = 0
  49.         while iS < len(nA[i]):
  50.             nA[i][iS] =( fA[i][0]*sA[iS][0] ) + ( fA[i][1]*sA[iS][1] ) +( fA[i][2]*sA[iS][2])
  51.             iS = iS + 1
  52.         i = i + 1
  53.     return nA
  54.  
  55. #Опишем матрицу поворота
  56. grad = 75
  57. matrixRotate = [[math.cos(math.radians(grad)),-math.sin(math.radians(grad)),0],[math.sin(math.radians(grad)),math.cos(math.radians(grad)),0],[0,0,1]]
  58. #Опишем матрицу масштабирования
  59. a = 2
  60. b = 2
  61. matrixResize = [[a,0,0],[0,b,0],[0,0,1]]
  62. #Опишем матрицу отражения
  63. matrixMirror = [[1,0,0],[0,-1,0],[0,0,1]]
  64. #Опишем матрицу переноса
  65. c = 2
  66. d = 2
  67. matrixMove = [[1,0,c],[0,1,d],[0,0,1]]
  68.  
  69. showPlot(myArray)
  70. showPlot(AxB(copy.deepcopy(myArray),matrixRotate))
  71. showPlot(AxB(copy.deepcopy(myArray),matrixResize))
  72. showPlot(AxB(copy.deepcopy(myArray),matrixMirror))
  73. showPlot(AxB(copy.deepcopy(myArray),matrixMove))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top